I a wordpress template file I want to show the next post link and if next post is not available then I want to show the previous post link.
I used the following code but it shows error message.
<?php if (next_post_link()) ? next_post_link('%link'); : previous_post_link('%link') ; ?>
I think it is php syntax error.
Any Help?
Try this:
<?php
echo (next_post_link()) ? next_post_link('%link') : previous_post_link('%link');
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.