Reputation: 791
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?
Upvotes: 0
Views: 260
Reputation: 899
Try this:
<?php
echo (next_post_link()) ? next_post_link('%link') : previous_post_link('%link');
?>
Upvotes: 1