Custom Post Types not showing after archive or recent posts query
-
Hello,
I have set up a Custom Post Type and in order to get the Category Widget to list the custom posts along with the default blog posts, I needed to add the code below to my functions file.
But now I see that the archives and the recent posts have the same issues. They see the default blogs posts but do not see the custom post types.
So my question is does anyone have some code that fixes the issue?
Thank you in advance,
//COMMENT - Allows CPTs to be Queried add_filter('pre_get_posts', 'query_post_type'); function query_post_type($query) { if(is_category() || is_tag() || is_home() && empty( $query->query_vars['suppress_filters'] ) ) { $post_type = get_query_var('post_type'); if($post_type) $post_type = $post_type; else $post_type = array('post','jobs','newsletters','articles','nav_menu_item'); $query->set('post_type',$post_type); return $query; } }
- The topic ‘Custom Post Types not showing after archive or recent posts query’ is closed to new replies.