Issue with custom query
-
I have a custom query on a page that only shows the videos, and I’m using WP page navi for the pagination (I’m willing to try other options if necessary). So when I click to go to the next page, it takes me to mydomain.com/videos/page/2 but that page gives a 404.
Here’s my code for the query:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args=array( 'post_type'=>'videos', 'paged'=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); /* DO STUFF IN THE LOOP */ get_template_part( 'content', get_post_format() ); endwhile; endif; /* PageNavi at Bottom */ if (function_exists('wp_pagenavi')){wp_pagenavi();} $wp_query = null; $wp_query = $temp; wp_reset_query(); ?>
What am I doing wrong? I have another custom query for just posts and the pagination on that works flawlessly.
Any help would be much appreciated.
- The topic ‘Issue with custom query’ is closed to new replies.