Pages

Friday, September 6, 2013

[resolved] WP-PageNavi with custom query and $paged variable


<?php

global $paged;
if( get_query_var( 'paged' ) )
$my_page = get_query_var( 'paged' );
else {
if( get_query_var( 'page' ) )
$my_page = get_query_var( 'page' );
else
$my_page = 1;
set_query_var( 'paged', $my_page );
$paged = $my_page;
}

$jobquery = new WP_Query( array( 'post_status' => 'publish', 'post_type' => 'job', 'paged' => $my_page )  );
if(count($jobquery->posts) > 0){
foreach($jobquery->posts as $jpost) {

?> <header class="entry-header">
<h1 class="entry-title"><?php echo $jpost->post_title; ?></h1>
</header><!-- .entry-header -->

<div class="entry-content">
<?php echo $jpost->post_content; ?>
</div><!-- .entry-content -->

<?php } wp_pagenavi( array( 'query' => $jobquery ) ); ?>
<?php }  wp_reset_query(); ?>

No comments: