I am using the WP_Query class to retrieve some posts according to variables set in url.
All working well until we get to paging. The second page (though having posts - tested it by making paged => 2) throws a 404. How can I fix this?
Note: Unusual method of getting author(director) data due to method of adding that content in backend.
<?php /* GET STUFF */
$director_id = get_query_var('author');
$reel = get_query_var('reel');
$info = get_query_var('info');
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$director_args = array(
'meta_key' => '_metabox_director',
'meta_value' => $director_id,
'paged' => $page,
'types' => $reel,
'posts_per_page' => 2,
'post_type' => 'clip',
'orderby' => 'menu_order',
'order' => 'ASC',
);
//query_posts($director_args);
$wp_query = new WP_Query();
$wp_query->query($director_args);
if ($wp_query->have_posts()) : ?>
<?php next_posts_link('Next' ); ?>
<?php previous_posts_link('Back' ); ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<!-- Loop the loop -->
<?php endwhile; ?>
<?php endif; ?>
Url vars on initial view are ?author=2&reel=commercials
and on second page ?author=2&reel=commercials?paged=2
but the query won't display the posts.
Thanks!
next_posts_link()
. Thanks :-)