Good afternoon, permalinks are output /% category% /% postname% /

The browser browser bar displays http: // localhost / categroy / primary-category / child-category / post.

If I follow the category links, everything is fine, if I display all the posts in this category in the main category, if I fall into the subcategory, I see all the posts in the subcategory, but when I remove the url category through functions.php

// Remove category from url add_filter('category_link', create_function('$a', 'return str_replace("category/", "", $a);'), 9999); 

either through .htaccess or a point without a difference, for some reason, posts of a subcategory stop displaying if I fall into a subcategory, but when I fall through the category it works and displays a list of posts in this category. I use the index.php template, everything is simple, <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

If I return the category back to the url, everything works.

  • one
    CNC games are fraught with bad consequences. But if you really want to remove the category from the URL, that is, the ready plugin wordpress.org/plugins/no-category-base-wpml - SeVlad
  • @SeVlad Thank you, the plugin helped all work. - Anton Essential

0