Wordpress: How do I retrieve next_post_url() and next_post_title()?
This is the HTML I would like to use in combination with Wordpress's next_post_link() and previous_post_link(). You can see that the URL and the title are wrapped by HTML tags and that there is even single_cat_title() in there. Because of this rater complex HTML setup I cannot easily use next_post_link() and previous_post_link().
So how can I achieve the following? I feel I'm missing tags like: next_post_url() and next_post_title().
<p class="prev-next clearfix">
<a href="http//loremipsum.com" class='prev <?php single_cat_title(); ?>'>
<span class="header">Previous article</span>
<span class="title">Lorem ipsum dolores a开发者_运维知识库met title</span>
</a>
<a href="http://foorbar.com" class='next <?php the_filmcom_category(); ?>'>
<span class="header">Next article</span>
<span class="title">Foo bar title</span>
</a>
</p>
I solved it by retrieving the next and prev posts using get_adjacent_post(). And then using get_permalink() and get_the_title().
<?php $nextpost = get_adjacent_post(true,'',false); ?>
<?php $prevpost = get_adjacent_post(true,'',true); ?>
<p class="prev-next">
<a href="<?php echo get_permalink($prevpost); ?>" class='prev <?php the_filmcom_category(); ?>'>
<span class="header">Previous article</span>
<span class="title"><?php echo get_the_title($prevpost); ?></span>
</a>
<a href="<?php echo get_permalink($nextpost); ?>" class='next <?php the_filmcom_category(); ?>'>
<span class="header">Next article</span>
<span class="title"><?php echo get_the_title($nextpost); ?></span>
</a>
</p>
精彩评论