Hi @eeyore:
Without being able to see the full context of your theme page I think you have at least two issues.
- You need to use
$wp_query
instead of$my_query
if you wantprevious_posts_link()
andnext_posts_link()
to work since they assume$wp_query
. - What @Jan Fabry mentioned; you need to capture the pagination yourself and pass it to
WP_Query
as a'paged'
parameter.
$url = $_SERVER['REQUEST_URI'];
if (strpos($url,'/page/')===false)
$paged = 1;
else
$paged = preg_replace('#^.*/page/([0-9]+)/.*$#','\1',$url));
$wp_query = new WP_Query('cat=". $id ."&showposts=1&paged={$paged}");
That said, why are you creating your own query on this page? Is it so you can set the number of posts per page to be 2? If so, there”s a much easier way and you can let WordPress handle pagination; add this to your theme’s functions.php
file:
add_action('pre_get_posts','yoursite_pre_get_posts2');
function yoursite_pre_get_posts2($query) {
$query->set('posts_per_page',2);
}