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
Template Name: Projects

<?php get_header();?>

    <section id="content">
        <section id="main">

                $loop = new WP_Query(array('post_type' => 'projects', 'posts_per_page' => 4));
                while ( $loop->have_posts() ) : $loop->the_post();

            <article class="post<?php if($i%2 == 0) { echo ' right'; }; $i++; ?>" id="post-<?php the_ID(); ?>">
                <h2><?php the_title(); ?></h2>
                <section class="entry">
                    <?php the_excerpt(); ?>


            <section id="map">
                <img src="<?php bloginfo('template_url') ?>/images/interactive-map.jpg" alt="Interactive Map" />

<?php get_sidebar(); ?>


<?php get_footer(); ?>

I have pagenavi set up right after the endwhile. It's not working, though. Anybody know how I can get this to work?

share|improve this question
see - wordpress.stackexchange.com/questions/4696/… (basically you need to hijack the $wp_query global and use it instead of $loop – onetrickpony Feb 17 '11 at 5:01
Thanks, that helped! – J82 Feb 17 '11 at 5:16
I followed the directions in there and the navigation shows now but when I go to page 2, I get an error. Here is the pastebin of what I have. If you can take a look and let me know if you notice anything wrong, I'd be forever grateful. Thank you. pastebin.com/RMZaE6Pi – J82 Feb 17 '11 at 5:52
what is the error you are getting? – Bainternet Feb 17 '11 at 9:45
@One Trick Pony: Can you move your comment to an answer, so John can accept it? Maybe include my comment in the referenced answer, because with the new version of WP-Pagenavi you can pass a query argument. John asked a followup question to get the paging working. – Jan Fabry Feb 17 '11 at 14:29
wp_pagenavi( array( 'query' => $loop ) );

should work with the code above. Don't hijack the main query if you can avoid it.

share|improve this answer
My source for this: plugins.trac.wordpress.org/browser/wp-pagenavi/trunk/… – John P Bloch Feb 17 '11 at 14:29
Indeed, the development version of WP Pagenavi (2.74-alpha) supports this. – scribu Feb 17 '11 at 14:34
Oh, I didn't realize this was the dev version. Oops! – John P Bloch Feb 17 '11 at 14:37
is this possible with paginate_links() ? – onetrickpony Feb 17 '11 at 14:46
paginate_links is somewhat more basic. Instead of giving it a query object, you tell it what the max number of pages are, what the current page is, and a few other parameters (like the format of the url, etc.) – John P Bloch Feb 17 '11 at 14:56

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.