Site icon Hip-Hop Website Design and Development

How can I get archives for particular class with out category_base within the url?

I am utilizing this code to get archives for a particular class:

perform extend_date_archives_add_rewrite_rules($wp_rewrite){
    $guidelines = array();
    $constructions = array(
        $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_date_permastruct(),
        $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_month_permastruct(),
        $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_year_permastruct(),
    );
    foreach( $constructions as $s ){
        $guidelines += $wp_rewrite->generate_rewrite_rules($s);
    }
    $wp_rewrite->guidelines = $guidelines + $wp_rewrite->guidelines;
}
add_action('generate_rewrite_rules', 'extend_date_archives_add_rewrite_rules');

It really works effective and I get an URL like:
instance.com/category_base/category_name/date/YYYY/MM

The issue is that I want to have an URL with out the category_base: instance.com/category_name/date/YYYY/MM

If I exploit a plugin to delete de “category_base” (like WP no class base) or just I exploit “str_replace” to delete the “category_base”, I get a 404 error web page in all pages and single pages.

What can I do?

Thanks.

Added notes:

If I exploit:

perform extend_date_archives_flush_rewrite_rules(){
    international $wp_rewrite;
    $wp_rewrite->flush_rules();
}
add_action('init', 'extend_date_archives_flush_rewrite_rules');
perform extend_date_archives_add_rewrite_rules($wp_rewrite){
    $guidelines = array();
    $constructions = array(
        $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_date_permastruct(),
        $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_month_permastruct(),
        $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_year_permastruct(),
    );
    foreach( $constructions as $s ){
        $guidelines += $wp_rewrite->generate_rewrite_rules($s);
    }
    $wp_rewrite->guidelines = $guidelines + $wp_rewrite->guidelines;
}
add_action('generate_rewrite_rules', 'extend_date_archives_add_rewrite_rules');

instance.com/category_name/YYYY works effective, however single and pages go to 404 web page. However If I solely use:

perform extend_date_archives_add_rewrite_rules($wp_rewrite){
    $guidelines = array();
    $constructions = array(
        $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_date_permastruct(),
        $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_month_permastruct(),
        $wp_rewrite->get_category_permastruct() . $wp_rewrite->get_year_permastruct(),
    );
    foreach( $constructions as $s ){
        $guidelines += $wp_rewrite->generate_rewrite_rules($s);
    }
    $wp_rewrite->guidelines = $guidelines + $wp_rewrite->guidelines;
}
add_action('generate_rewrite_rules', 'extend_date_archives_add_rewrite_rules');

Then all single and pages work effective, however instance.com/category_name/YYYY goes to 404.
Any thought? I refresh permalinks, and I proceed with the issue 🙁