Conditional next_ & previous_post_link
-
Hi,
I’m building a website containing a fair amount of posts in different categories.
I’m using a previous & next post button using the post_link function.
Browsing through the posts it all works as it should but when I reach the last post of that category the button disappears (which normally is a good thing) but I want the button to turn into a button that takes you back to the category overview.The permalinks are setup like this
localhost/work/2012/postname
localhost/work/2012/postname2
localhost/work/2012/postname3
etc..So reaching the last post in the cateogry 2012 should give me a link back to
localhost/work/2012The code I have right now looks like this:
<?php previous_post_link('%link', '<div class="arrow-left"></div>', TRUE); if (empty( $previous_post_link )): ?> <a href="<?php echo esc_url( $category_link ); ?>"><div class="arrow-left"></div></a> <?php endif; ?>
Does anyone have an idea?
Thanks!
Regards
Marcus
- The topic ‘Conditional next_ & previous_post_link’ is closed to new replies.