You’ve associated your Custom Post Types with Default Categories or Default Tags but those posts aren’t showing up when you click those from your sidebar. What’s up?
By default, WordPress only shows the post_type
post in its Category or Tag archives. This is actually handled in the pre_get_posts
filter. To make your custom post types show up, you need to add the following to your functions.php
in your theme:
1 2 3 4 5 6 7 8 9 10 11 12 |
add_filter('pre_get_posts', 'query_post_type'); function query_post_type($query) { if(is_category() || is_tag()) { $post_type = get_query_var('post_type'); if($post_type) $post_type = $post_type; else $post_type = array('post','review'); $query->set('post_type',$post_type); return $query; } } |
Add your own post_type
to the array('post','review')
above, replacing review
. Don’t remove post
or Categories and Tags won’t work for your Posts any longer, either.