Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

get_adjacent_post wordpress

<?php
$prev = mod_get_adjacent_post('prev', array('post', 'custom1', 'custom2'));
$next = mod_get_adjacent_post('next', array('post', 'custom1', 'custom2'));
?>

<?php if($prev) : ?>
    <a href="<?php echo get_permalink($prev->ID)?>">« Go back in time</a>
<?php endif; ?>

<?php if($next) : ?>
    <a href="<?php echo get_permalink($next->ID)?>">Next: <?php echo $next->post_title; ?> »</a>
<?php endif; ?>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wordpress
ADD COMMENT
Topic
Name
2+4 =