So my project is to display each time one image from the Wordpress media library.
The WordPress page will display the newest image and also display a << next button that links to the next image.
The user will click that link and will see the next image.
And like this again and again until complete.
So I have the code below:
The first image is displayed
Also the << next image
but if I click the link it takes me to a Page Not Found
What am I doing wrong?
Thanks
<?php
$query_images= new WP_Query( array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => 1,
'order' =>'DESC'
) );
if ( $query_images->have_posts() ) {
while ( $query_images->have_posts() ) {
$query_images->the_post();
the_content();
}
next_posts_link('<< next image', $query_images->max_num_pages);
wp_reset_postdata();
}
else {
?>
<p><?php echo( 'Sorry, No images' ); ?></p>
<?php } ?>