WP How-to: 10 posts per page with page navigation on custome template... I'm stuck

I’m stuck please help… I can’t figure out how-to get page navigation, 10 posts per page… Is it screwy b/c I’m only showing posts for one category? On another template I’m having the same exact problem except it’s showing all categories EXCEPT for one (CAT ID=3 //CAT ID=-3)… If someone could help me out that would be great and much much MUCH appreciated. Here’s what the page looks like:

Template Name: Memorials
<?php get_header(); ?>
<?php if (have_posts()) : ?>

<div id="content">
<div id="post" class="post clearfix">
<div id="blog-heading"><h1>Memorials for Loved Ones Lost</h1></div>

    $recentPosts = new WP_Query();
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<div id="h2-memorial">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endwhile; ?>

<div class="page-nav">
<?php wp_pagenavi(); ?>    </div>

<!--page.php end-->
<?php endif; ?>
<?php get_sidebar(' '); ?>
<?php get_footer(' '); ?>

Thank you in advance!

Try posts_per_page=10 as showposts was deprecated source


Dude you’re friggin awesome! That’s giving me the 10 posts per page! Can you help me get page navigation to work now?! There are 14 memorials only 10 are showing on http://stlheroinhelp.org/memorials/ - I can’t get page navigation on the bottom like it is on [URL=“http://stlheroinhelp.org/?s=heroin”]http://stlheroinhelp.org/?s=heroin (example of navigation on bottom).

Not sure what code I’m missing above ^^^ or what’s out of place/out of order.

where is next_posts_link() and previous_posts_link() function? you should add these function in your page. for more details you can search the function in wordpress.org.

Okay, I am unsure at this point, but some debugging may help to see what is going on. Replace the following code

<?php wp_pagenavi(); ?>


<?php var_dump($GLOBALS['wp_query']);
wp_pagenavi(); ?>

That should produce some kind of output at the bottom of the page, I would need that copied/pasted here so I can see what the value of $GLOBALS[‘wp_query’] is (as the WP-PageNavi plugin is dependent on that value)

Okay, I have it solved


    $recentPosts = new WP_Query(); 


    $recentPosts = new WP_Query( array( 'cat' => 3, 'posts_per_page' => 10, 'paged' => get_query_var('paged') ) ); 

Then replace

<?php      wp_pagenavi(); ?>


<?php      wp_pagenavi( array( 'query' => $recentPosts ) ); ?>


You are the friggin MAN! I really can’t thank you enough! Thank you thank you thank you! You solved what’s been eating at me for 2-entire days… And you were just helping. Thank you so much!

-Scott G.