I cannot figure out how to make next_posts_link() work within my custom WP_Query. Here is the function:
function artists() {
echo '<div id="artists">';
$args = array( 'post_type' => 'artist', 'posts_per_page' => 3, 'paged' => get_query_var( 'page' ));
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<a class="artist" href="'.get_post_permalink().'">';
echo '<h3 class="artist-name">'.get_the_title().'</h3>';
$attachments = attachments_get_attachments();
$total_attachments = count( $attachments );
for( $i=0; $i<$total_attachments; $i++ ) {
$thumb = wp_get_attachment_image_src( $attachments[$i]['id'], 'thumbnail' );
echo '<span class="thumb"><img src="'.$thumb[0].'" /></span>';
}
echo '</a>';
endwhile;
echo '</div>';
next_posts_link();
}
Can anyone tell me what I am doing wrong?
Thanks
2 s
try passing max_num_pages to the function:
next_posts_link('Older Entries »', $loop->max_num_pages);