MayerAnnamaria
6/4/2017 - 10:16 AM

previous next button on posts

previous next button on posts

$prev_post = get_adjacent_post(false, '', true);
if(!empty($prev_post)) {
echo '<a href="' . get_permalink($prev_post->ID) . '" title="' . $prev_post->post_title . '">' . $prev_post->post_title . '</a>'; }

---------------------------------------

$next_post = get_adjacent_post(false, '', false);
if(!empty($next_post)) {
echo '<a href="' . get_permalink($next_post->ID) . '" title="' . $next_post->post_title . '">' . $next_post->post_title . '</a>'; }

----------------------------------------------
		<div class="links-next-before">
			<?php 	
				$prev_post = get_adjacent_post(false, '', true);
				if(!empty($prev_post)) { ?>
					<div class="left">
						<button type="button" class="btn btn-blue">
							<?php echo '<a href="' . get_permalink($prev_post->ID) . '" title="' . $prev_post->post_title . '">' . $prev_post->post_title . '</a>'; ?>
						</button>
				<?php } ?>
					</div>
			<?php	$next_post = get_adjacent_post(false, '', false);
					if(!empty($next_post)) { ?>
						<div class="right">
							<button type="button" class="btn btn-blue">
								<?php echo '<a href="' . get_permalink($next_post->ID) . '" title="' . $next_post->post_title . '">' . $next_post->post_title . '</a>'; ?>
								</button> 

						</div>
					<?php } ?>
		</div>