Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Include Custom Post Types Categories to the main query

function custom_post_type_cat_filter($query) {
  if ( !is_admin() && $query->is_main_query() ) {
    if ($query->is_category()) {
      $query->set( 'post_type', array( 'post', 'YOUR CPT' ) );
    }
  }
}

add_action('pre_get_posts','custom_post_type_cat_filter');
Source by wordpress.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #Include #Custom #Post #Types #Categories #main #query
ADD COMMENT
Topic
Name
4+6 =