1

I've created a CPT & used the default category & tags instead of creating new taxonomy for those CPT.

Now while generating the 'list all'/ archive page, my query is returning only the posts that added through the default posts> section of admin menu.

What if I want them separately? Should I use independent page templates with custom query?

0

Custom post types are not included in the ordinary archives by default, even if registered with the taxonomies argument. You will need to add the post type to the query yourself.

add_action(
  'pre_get_posts',
  function($qry) {
    if ($qry->is_main_query() && $qry->is_category()) {
      $qry->set('post_type',array('post','yourposttype'));
    }   
  }
);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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