First of all, I've been all over Google, StackExchange and Codex but still can't solve my problem. It might be simple; am not sure. I have the following function that lists custom posts. The page has more than one query but only one (this one) make use of pagination. It's on the front page - which is set to static.
Here is the function:
function wight_listings()
{
global $wp_query;
global $page;
$backup = $wp_query;
$wp_query = NULL;
$cur_page = $page; //get_query_var('page') ? get_query_var('page') : 1;
$args = array(
'post_type' => array('wight_listing'),
'posts_per_page' => 7,
'paged'=>$cur_page
);
$wp_query = new WP_Query($args);
?>
<?php if ( $wp_query->have_posts() ) : ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
.
.
.
<?php endwhile; ?>
<div id="nav-posts" style="margin-top: .5em;">
<div style="float:left;"><?php previous_posts_link('Previous Listings «'); ?></div>
<div style="float:right;"><?php next_posts_link('» Next Listings'); ?></div>
<div class="clear"></div>
</div>
<?php else: ?>
<p>Oh no! There's nothing to show. :(</p>
<?php endif; ?>
<?php
$wp_query = NULL;
$wp_query = $backup;
}
The 'Next listings' links shows up linking only to page 2 no matter what page am on and the 'Previous Listings' link never show up.
What am I doing wrong?
WP: 3.5.2