WP_Query Pagination

Hi @eeyore:

Without being able to see the full context of your theme page I think you have at least two issues.

  1. You need to use $wp_query instead of $my_query if you want previous_posts_link() and next_posts_link() to work since they assume $wp_query.
  2. 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);
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)