I have the code:
<a href="" id="psingle_prev" class="psingle_bts clearfix"><span class="psingle_arrow" id="arrow_prev"> </span> Previous</a>
<a href="" id="psingle_next" class="psingle_bts clearfix">Next <span class="psingle_arrow" id="arrow_next"> </span></a>
I would like to add the url for <strong>href=""</strong>, dynamically using a PHP function.
Nick Parsons answers:
Try this:
<?php echo strip_tags( get_next_posts_link() ); ?>
Lucian Florian comments:
outputs nothing
Nick Parsons comments:
Sorry, working on it. Just realized my mistake!
Nick Parsons comments:
OK, update:
<?php $next_post = get_adjacent_post(false,'',true) ; echo get_permalink($next_post); ?>
Nick Parsons comments:
Your code would look like:
<a href="<?php echo get_permalink(get_adjacent_post(false,'',false)); ?>" id="psingle_prev" class="psingle_bts clearfix"><span class="psingle_arrow" id="arrow_prev"> </span> Previous</a>
<a href="<?php echo get_permalink(get_adjacent_post(false,'',true)); ?>" id="psingle_next" class="psingle_bts clearfix">Next <span class="psingle_arrow" id="arrow_next"> </span></a>
Lucian Florian comments:
good job, thank you.
MagoryNET answers:
Rather:
echo next_posts();
echo previous_posts();
Lucian Florian comments:
outputs nothing
Michael Fields answers:
One of these depending on which type of view you are targeting:
$prev = get_previous_post();
if ( isset( $prev->ID ) ) {
$url = get_permalink( $prev->ID );
}
$next = get_next_post();
if ( isset( $next->ID ) ) {
$url = get_permalink( $next->ID );
}