Support » Plugin: Custom Post Type UI » Custom Post Type not Showing Catagory?

  • Resolved WPDragon


    Hello..i created a Custom Post Type, and it works fine…however, I noticed when I select a ‘Category’ for the custom post – that it wont display any of the results for all the posts in this category together on the site.

    The “Category” works fine for all my normal posts, however it seems to only not work with my Custom Post Type.

    Any help would be greatly appreciated.


Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Michael Beckwith


    You’ll need to query for more than just the “posts” post type in your category archives. I highly recommend doing that with the pre_get_posts action hook.

    Hi @michael Beckwith – thank you for the reply.

    The category.php page has a code like this below…so, if my Custom Post Type is called “Games” …then would it be like this?

            'ignore_sticky_posts' => 1,
            'posts_per_page' => $postsperpage,
            'paged' => $paged,
            'cat' => $cur_cat_id ) );
     <?php add_action( 'pre_get_posts', 'Games' ); ?>

    I’m fairly new to WordPress, so bare with me. 🙂 thank you.

    Plugin Author Michael Beckwith


    you’re mixing a lot of stuff up, with that attempt, but that’s ok, you’re learning.

    I’d recommend putting the following into your theme’s functions.php file. It needs to go in that file.

    function add_post_type_to_category_archive( $query ) {
        if ( is_admin() || ! $query->is_main_query() )
        if ( is_category( 'MY CATEGORY SLUG' ) ) {
            $query->set( 'post_type', array( 'post', 'MY CUSTOM POST TYPE SLUG' ) );
    add_action( 'pre_get_posts', 'add_post_type_to_category_archive', 1 );

    Replace “MY CATEGORY SLUG” with the actual category slug you’re trying to alter. Replace “MY CUSTOM POST TYPE SLUG” with the actual post type slug you registered.

    This snippet will set the post type to query to “post” and whatever your custom post type is ONLY IF you’re on the category archive for the category that you’ll specify.

    It worked!..Thank you very much for your help with this!

    One lil’ thing..i noticed it called the page “Archives” – most of the other Category pages have the Name of the Category as the header…is there a way to change the name, so it says “Games” – instead of “Archives” as the Title?

    Plugin Author Michael Beckwith


    That would be a change needed to be done to your theme files, which is outside the scope of our plugin.

    ohh okay, Thanks again for your help..i appreciate it!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom Post Type not Showing Catagory?’ is closed to new replies.