Alkorr
Member
Posted 10 months ago #
Hi! I'm using <?php next_post_link(); ?> to show a link to the next post. But if there is no 'next post', how can I hide the HTML code I'm calling when there is a 'next post' so when there is no 'next post' nothing is showing at all?
Thanks for your help! :)
The question is not clear!
if there is no next post then there won't be any thing to show.
maybe you can get some ideas here: http://www.transformationpowertools.com/wordpress/advanced-styling-of-the-prev-next-post-links
generally:
<?php if(get_adjacent_post(false, '', true)) {
/*the previous post link and its html*/
} else {
/*either nothing or some spaceholder if no previous post*/
} ; ?>
<?php if(get_adjacent_post(false, '', false)) {
/*the next post link and its html*/
} else {
/*either nothing or some spaceholder if no next post*/
} ; ?>
Alkorr
Member
Posted 10 months ago #
Thank you very much alchymyth, this is exactly what I was looking for!
My question may seemed unusual like nsathees pointed out, but you always manage to find a solution. You're a WP God, really :)