Title: Problem with Categories
Last modified: August 31, 2016

---

# Problem with Categories

 *  Resolved [ValeriaK](https://wordpress.org/support/users/valeriak/)
 * (@valeriak)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/)
 * Hi!
    I’m having problem, that when I click on the category name in the blog it
   doesn’t show any posts 8althought in dashboard it shows how many posts are there.
   I’m getting this:
 * No entries were found under the The Hair category either because they were not
   published or this category has been excluded from the Blog section.
 * [https://wordpress.org/plugins/custom-post-type-ui/](https://wordpress.org/plugins/custom-post-type-ui/)

Viewing 15 replies - 1 through 15 (of 25 total)

1 [2](https://wordpress.org/support/topic/problem-with-categories-20/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/problem-with-categories-20/page/2/?output_format=md)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931379)
 * The query on the frontend likely isn’t knowing it needs to query for this custom
   post type as well. It’s sticking to just the “post” post type.
 * You’ll need to do some quick code edits for this, but the following should help.
   Add it to your theme’s functions.php file. Don’t hesitate to ask someone for 
   help if you’re not comfortable making the edits yourself. Replace the “ENTER 
   POST TYPE SLUG HERE” with the actual slug for your post type.
 *     ```
       function valeriak_add_custom_types_to_tax( $query ) {
           // Prevent unintended effects in the admin and non-main queries
           if ( is_admin() || ! $query->is_main_query() ) {
               return;
           }
   
           if ( is_category() || is_tag() ) {
               $post_types = array( 'post', 'ENTER POST TYPE SLUG HERE' );
               $query->set( 'post_type', $post_types );
               return $query;
           }
       }
       add_filter( 'pre_get_posts', 'valeriak_add_custom_types_to_tax' );
       ```
   
 *  Thread Starter [ValeriaK](https://wordpress.org/support/users/valeriak/)
 * (@valeriak)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931455)
 * Hi! Thanks for the answer.
    I can replace it, but I couldn’t find any “ENTER 
   POST TYPE SLUG HERE” in my functions.php file. I made search in the file with“
   post type” got nothing, But got this with “slug” search:
 * Line 408: * [@see](https://wordpress.org/support/users/see/) get_term_by() You
   can get a category by name or slug, then pass ID to this function
 * Line 431: * [@see](https://wordpress.org/support/users/see/) get_term_by() You
   can get a category by name or slug, then pass ID to this function
 * Line 480: $name = ( $nicename ) ? $parent->slug : $parent->name;
 * Line 1243: $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var
 * Can you help with where I should incert the code you gave me?
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931459)
 * you’re not going to find “ENTER POST TYPE SLUG HERE” in your functions.php. You
   need to actually enter the slug you’re using for your post type in place of that.
 * You need to add my snippet above to your functions.php. It’s not going to be 
   there already. Then replace the “ENTER POST TYPE SLUG HERE” bit with the first
   field you see when you edit the post type settings in CPTUI.
 * Example. Say you made a post type of “movies”.
 *     ```
       $post_types = array( 'post', 'movies' );
       ```
   
 * Hope that clears up some confusion from my previous reply.
 *  Thread Starter [ValeriaK](https://wordpress.org/support/users/valeriak/)
 * (@valeriak)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931473)
 * Thanks, I got it now. One question left – where in the file functions.php I should
   insert this code? Can I insert it at the end of evething or there is a specific
   place for that?
    And I should copy this code for each POST TYPE slug, right?
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931479)
 * Doesn’t matter TOO much where in the functions.php file you place it, as long
   as you’re not placing it in the middle of other code or function declarations.
   No need to cause fatal errors on the site. Scary thought.
 * For adding other post types to this, you don’t need to repeat ALL of it, just
   need to modify the line below:
 *     ```
       $post_types = array( 'post', 'movies', 'SECOND CPT', 'THIRD CPT' );
       ```
   
 * Just replace the “SECOND CPT” and so on with the slugs, just like you did the
   first one. Keep them separated by commas.
 *  Thread Starter [ValeriaK](https://wordpress.org/support/users/valeriak/)
 * (@valeriak)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931500)
 * Well, I added the code to the end of functions.php and added those slugs separeated
   by comma as you suggested in the last comment.
    So, when I use now the categories
   in the menu, they do not appear like they should.. I mean when I click on them
   I can see the list of posts which belong to this category, but I cannot see them
   as they show normally with photo, tags, I can see ONLY names of the posts in 
   the category in the form of list.. Is there a way they canappear normally like
   with photos and etc..? I can make a screen shot or smth if I didn’t explain myself
   clear..
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931502)
 * A screenshot would help, but its sounding like it’s probably edits needing to
   be made at the template level for your current theme, which our plugin doesn’t
   touch on at all.
 *  Thread Starter [ValeriaK](https://wordpress.org/support/users/valeriak/)
 * (@valeriak)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931515)
 * I’ll give you the link. here is how it is normal appears:
    [http://www.valeriaspeck.com/the_review/](http://www.valeriaspeck.com/the_review/)
   and the_review is the pots type slug,
 * but here is how the category appears now (and it never appeared like that before):
   
   [http://www.valeriaspeck.com/category/the-scientific-opinion/](http://www.valeriaspeck.com/category/the-scientific-opinion/)
 * Is there any solution to make the second look like the first again?
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931516)
 * At least based on what I can tell via the classes on the <body> tag, you’re dealing
   with 2 different archive types.
 * The first url has these classes:
 *     ```
       archive post-type-archive post-type-archive-the_review u-design-responsive-on u-design-menu-auto-arrows-on  u-design-fixed-menu-on wpb-js-composer js-comp-ver-4.9.1 vc_responsive no_title_section
       ```
   
 * The second one has these:
 *     ```
       archive category category-the-scientific-opinion category-62 u-design-responsive-on u-design-menu-auto-arrows-on  u-design-fixed-menu-on wpb-js-composer js-comp-ver-4.9.1 vc_responsive no_title_section
       ```
   
 * Chances are you are dealing with a different template file in the theme, probably
   one that isn’t as developed or done up to match.
 * I’d check for something like category.php or archive.php in the theme.
 *  Thread Starter [ValeriaK](https://wordpress.org/support/users/valeriak/)
 * (@valeriak)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931517)
 * yeah I saw the differences. The first one is a new post type I’ve created and
   the second is the category. But my categories never displaid in this mode before
   I created post types with the plugin.
    Then the categories didn’t see the posts
   from the other post types and after adding the code you gave me above, the categories
   with the posts from new post types are displaid only in this mode. And I truly
   have no idea what to do. I cannot ask help from the support of my theme because
   in reality it only shows like this with new post types…. How can I resolve it
   and still be able to use your plugin? (because the plugin helps me so much in
   other stuff..)
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931518)
 * It’s not a problem with the plugin though. It’s a problem with the types of archives
   you’re seeing at the links aboe and the template files being selected from the
   theme to render the page.
 *  Thread Starter [ValeriaK](https://wordpress.org/support/users/valeriak/)
 * (@valeriak)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931521)
 * I cannot agree with you. It is the common problem which happens online with many
   plugin/theme creators, you guys (not all, but many of you!) see the person who
   doesn’t understand codes and just blame one another, instead of trying to help
   that person…
 * What I’ve learnt from all situations is if the problem happens AFTER I install
   the plugin, the problem HAPPENED because of the PLUGIN. The plugin made its changes,
   or whatever, but please, if you don’t wanna help just say so, don’t start saying
   that the plugin didn’t interfere and it is basicaly not your problem…
 * I know the pluging is free, the support is free, if you don’t like doing it for
   free start charging, but not that “blaming whatever or whoever” thing you do.
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931522)
 * _*Does the hands timeout thing*_
 * > I know the pluging is free, the support is free, if you don’t like doing it
   > for free start charging, but not that “blaming whatever or whoever” thing you
   > do.
 * That’s an unfair thing to say and believe me when I write this: _Michael knows
   exactly what he’s talking about._ He is providing support for free and I’d appreciate
   if you’d take a more conciliatory tone in these forums.
 * This is a complex plugin and Custom Post Types are not a trivial topic, though
   it could be once you get a handle on them.
 * _Back top the topic at hand._
 * > I’m having problem, that when I click on the category name in the blog it doesn’t
   > show any posts 8althought in dashboard it shows how many posts are there. I’m
   > getting this:
   > No entries were found under the The Hair category either because they were 
   > not published or this category has been excluded from the Blog section.
 * Start with the basics: what theme are you using to generate the archive? Can 
   you provide a link to your site? Apologies if you’ve already shared it above.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931523)
 * Technically, the solutions proposed and discussed weren’t even related to our
   plugin. The post types were being registered successfully and as expected. Everything
   else was myself helping out anyway, to modify the default behavior of the archives
   for WordPress.
 * The solution with the filtering, modifies what post types are queried for when
   creating the archives. Specifically if the archive being viewed is a category
   archive or tag archive.
 * The amount of output and display is dictated by the template files. However, 
   without knowing either what theme you’re using or what files are available in
   the list. If I did, I could provide files to look at and compare so we could 
   determine exactly why the output is different between the two.
 * Remember, the provided links earlier are a case of the post type archive, and
   the category archive.
 * As a test, to see if what you’re seeing is indeed provided by query alterations
   suggested in this forum thread, remove the suggested code temporarily and see
   if it brings back different, expected output results. If not, then we know that’s
   not the source for sure.
 * If you have more questions, I’m willing to help look things over still, but there
   will be work on your end. I’m willing to explain things so that you can learn
   more as well.
 *  Thread Starter [ValeriaK](https://wordpress.org/support/users/valeriak/)
 * (@valeriak)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-categories-20/#post-6931536)
 * I have access to all the files. Tell me what information I should give you, and
   I will.
    My theme name is udesign: [http://themeforest.net/item/udesign-responsive-wordpress-theme/253220](http://themeforest.net/item/udesign-responsive-wordpress-theme/253220)
 * I’ve removed the code you gave me above and this is what I was getting (the problem
   why I started asking your help):
 * No entries were found under the The Skin category either because they were not
   published or this category has been excluded from the Blog section.
 * I’ve put the code back, at least it shows the category in “the list” format.
 * I willing to solve and learn. What else can I do to solve this, so the categories
   will show normally?

Viewing 15 replies - 1 through 15 (of 25 total)

1 [2](https://wordpress.org/support/topic/problem-with-categories-20/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/problem-with-categories-20/page/2/?output_format=md)

The topic ‘Problem with Categories’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-type-ui/assets/icon-256x256.png?rev=2744389)
 * [Custom Post Type UI](https://wordpress.org/plugins/custom-post-type-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-post-type-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-type-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-type-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-type-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-type-ui/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)

 * 25 replies
 * 4 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-categories-20/page/2/#post-6931596)
 * Status: resolved