0

I used the Custom Post UI plugin to create a custom post type called 'business_sold'. I assigned each custom post to one of six categories and an additional one called 'All'.

I used a standard WP widgetized menu to list the 'Business Sold' categories, but my custom posts are not called on a search of any category. I can see that WP has recognized the category assignment. Single-business_sold.php is working fine, but neither category-business_sold or archive-business_sold are working.

I cannot figure out what I'm doing wrong. Can anyone help me please?

1 Answer 1

1

Category archive by default it search for posts and not your custom type, you need to tell WordPress to search for your custom type, paste this code in your theme's functions.php file:

function cpt_Search_category_Filter($query) {
    $post_type = array('post','business_sold');
    if ($query->is_search || $query->is_category) {
        $query->set('post_type', $post_type);
    };
    return $query;
};

add_filter('pre_get_posts','cpt_Search_category_Filter');

and you should be fine.

3
  • Oh my god - you saved me. I can't thank you enough!! I assumed that categories and tags were being recognized by custom post types - And I checked boxes within the plugin to make sure they would be. Seriously, I can't thank you enough!! I LOVE this forum. Way more informative and helpful than anything within the WP forums.
    – mktggirl
    May 11, 2011 at 20:50
  • Welcome to our little community, and glad i could help.
    – Bainternet
    May 11, 2011 at 21:51
  • I have one more little problem. If it's not too much trouble, do you have ideas as to why the system would not be reading my archive-business_sold.php file? I've read through a number of articles and it appears that it's not an uncommon problem. I'm wondering if my plugins are conflicting. I'm using Custom Post UI and I also activated Custom Post Type archives and Custom Post Permalinks, although I'm not sure I need either of them. I've disables individually and I can't isolate the issue.
    – mktggirl
    May 11, 2011 at 23:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.