Reputation: 199
I am a bit of a WP noob so I am not sure how to go about this. I have a post where I want to display a list of images. However I want the users to be able to click next and previous so they can cycle through the images as if they are on different pages.
I added this bit of code to break up the post into multiple pages:
<!--nextpage-->
Currently when I add this it displays 1 2 3 Next etc... then when you click next or one of the numbers it changes to Previous 2 3 etc.. Is there a way to modify this so It only display next and previous and not the numbers inbetween?
I tried to modify this bit of code for the singlepost.php but every time I did I just ended up breaking it:
<?php wp_link_pages(array('before' => '<div class="pagination">', 'after' => '</div>', 'link_before' => '<span class="current"><span class="currenttext">', 'link_after' => '</span></span>', 'next_or_number' => 'next_and_number', 'nextpagelink' => __('Next','mythemeshop'), 'previouspagelink' => __('Previous','mythemeshop'), 'pagelink' => '%','echo' => 1 )); ?>
Any help would be appreciated, thanks!
Upvotes: 1
Views: 3475
Reputation: 70
Hi what i think you are looking for is this
<?php
global $page, $pages;
// If the current page equals the last page
if ($page == count($page)):
$previous_post = get_previous_post();
// Then spit out the next link
?>
<a href="<?php echo get_permalink( $previous_post->ID ); ?>"><span style="float:left;" class="meta-item">Previous Gallery</span></a>
<?php
// End the if statement
endif;
wp_link_pages( array( 'before' => '<div style="text-align: center;" class="page-link-next-prev">',
'after' => '', 'previouspagelink' => '<span style="float:left;" class="meta-item">Previous post</span>', 'nextpagelink' => '',
'next_or_number' => 'next' ) );
echo('<span style="text-align: center;">'.$page.' of '.count($pages).'</span>');
wp_link_pages( array( 'before' => '', 'after' => '</div>', 'previouspagelink' => '',
'nextpagelink' => '<span style="float:right;" class="meta-item">Next post</span>', 'next_or_number' => 'next' ) );
?>
<?php
// If the current page is first page
if ($page == count($pages)):
$next_post = get_next_post();
// Then spit out the next link
?>
<a href="<?php echo get_permalink( $next_post->ID ); ?>"><span style="float:right;" class="meta-item">Next Gallery</span></a>
<?php
// End the if statement
endif; ?>
Upvotes: 1