WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having a tough time getting this to work. It's not the first time I run into problems with pagination, or I would say with WPs URL system.

Basically I have this URL:


and loads up the taxonomy-location.php template.

Now, I'm adding the pagination feature to the theme. So I have this URL:


and it won't load the taxonomy-location.php template, it actually loads the 404 template.

This is what the debug bar shows:


It seems like it's getting the right values, WP is just not loading up the correct template.

EDIT (Moved over from the comment links)


add_rewrite_rule( 'location/([^/]+)/page/([0-9]{1,})/?$', 'index.php?location=$matches[1]&paged=$matches[2]', 'top' );


  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

  <h2>"<?= ucwords(get_query_var('location')); ?>" Venues</h2>

  <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('venue_thumb'); ?></a>

  <?php endwhile; ?>

    <?php wp_pagenavi(); ?>

  <?php else : ?>

      <h1>No posts found</h1>

<?php endif; ?>
share|improve this question
Lots of things can mess this up. Do you have any plugins installed? Have you used "query_posts" in your development? – tollmanz Nov 28 '11 at 3:54
I do have a couple of plugins installed. I have, but only in the custom templates. It doesn't make sense that using query_posts would affect it since the template is not being loaded at all. – criticerz Nov 28 '11 at 4:25
"query_posts", if used incorrectly, can have significant effects on the WordPress environment. In particular, it can change the main WP query which affects things like pagination. Can you do a pastebin of your template and your functions.php file? – tollmanz Nov 28 '11 at 4:43
@criticerz All your additional info is spread around comments. Please don't do that. Always update/edit your question and add the info to it. Then notify people in comments about your update. – kaiser Mar 13 '13 at 14:50

Try adding 'paged' => get_query_var( 'page' ) to your query.

EDIT : For pagination to work properly the posts per page should be greater than 'Blog pages show at most' under Settings-> Reading section of the WordPress Admin. So there are two ways you can make this work out.

  1. You can set 'Blog pages show at most' to 1. This would show 1 post in all the blog pages unless you specify post_per_pages specifically for each query.
  2. The other option you have would be to use the pre_get_posts filter.

Example of pre_get_post filter to limit the no. of posts on a location taxonomy archive page to 2 posts per page.

function location_posts( $query ) {
    if( is_tax( 'location' ) ) {
        $query->set('posts_per_page', '2');
    return $query;
add_filter('pre_get_posts', 'location_posts');
share|improve this answer
I am using that on my query already: cl.ly/3W2p220Z2t2w2e1e2L3A – criticerz Nov 28 '11 at 4:26
You are using get_query_var('paged'). Try using get_query_var('page'). Notice 'page' instead of 'paged'. – Joshua Abenazer Nov 28 '11 at 4:29
Tried that and nothing. I'm pretty sure it's supposed to be "paged". Anyways, the issue I'm having doesn't even get to the query_posts. My problem is that once I add the "page/2" to the URL, it won't load the taxonomy-location.php template. – criticerz Nov 28 '11 at 4:34
Can you tell me what 'Blog pages show at most' is set to under Settings-> Reading in the Dashboard? – Joshua Abenazer Nov 28 '11 at 4:44
Sure here you go: cl.ly/3h3T38413B0G2r0d0O2d – criticerz Nov 28 '11 at 14:03
register_post_type( 'lifestyle',
                'label' => __('Lifestyle', 'tmi'), 
                'public' => true, 
                'show_ui' => true,
                'show_in_nav_menus' => true,
                'rewrite' => true,
                'hierarchical' => true,
                'menu_position' => 5,
                'exclude_from_search' =>false,
                'supports' => array(

    register_taxonomy('lifestylecat', __('lifestyle', 'tmi'),array('hierarchical' => true, 'label' =>  __('Categories', 'tmi'), 'singular_name' => __('Category', 'tmi'))
share|improve this answer
Almost there. Please add an explanation to make this a legitimate answer. – Brian Fegter Oct 8 '12 at 13:49
How does this relate to the answer? Please edit your question or delete it. – kaiser Mar 13 '13 at 14:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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