I'm having an issue getting my custom taxonomy page to paginate correctly. I looked through other examples posted on this forum, but I could not get my second page to not return a 404 error page. Here are my details

  • Custom Tax: Study_Tags
  • Example Terms: Community, Economy, Crime...
  • Custom Taxonomy Page: taxonomy-study_tags.php
  • Posts Per Page: 5 (set in Reading Settings, global for all pages/posts on site)

I am using a Custom Post Type "Study" with the custom taxonomy "Study Tags", which is why i feel I need to use the "query_posts()" function.

I only want to show parent pages in the results, as each "Study" CPT can have children page with study details, presentations... etc.

My information to setup the query

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array_merge( $wp_query->query_vars, 
            'post_type'=> 'study',
            'post_parent' => '0',
            'paged' => $paged,
            'order' => 'ASC',


$wp_query->query_vars passes for example "[study_tags] => community" when var_dump() is used, so I know it is transmitting the correct term to the custom tax page.

Any ideas how to get a second page of results?


1 Answer 1


First of all: never use query_posts: when you need to change the main query, is a lot better use the pre_get_posts hook: your site users will thank you, once performance will increase.

If the custom taxonomy study_tags is used only for study CPT the only reason to change default query is to set post parent to 0.


function set_study_parent( $query ) {
  if ( ! is_admin() && is_main_query() && is_tax('study_tags') ) {
    $query->set( 'post_parent', 0 );

Then in your taxonomy-study_tags.php template, you can just use the loop. Pagination will work without doing anything else.

  • 1
    +1. Never EVER EVER EVER use query_posts(). It's amazing how easily pagination issues disappear when replacing query_posts() with a proper pre_get_posts filter. Oct 1, 2013 at 14:03

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