Problem: I would like to show some content based on whether or not there is an adjacent post to the current post.
Solution: Here is the custom shortcode for reference:
function ts_get_adjacent_post_url_func($atts) { global $post; $previous = ($atts['previous'] == "1"); $adjacent = get_adjacent_post( false, '', $previous); return get_the_permalink($adjacent); } add_shortcode("ts_get_adjacent_post_url", "ts_get_adjacent_post_url_func");
If no adjacent post exists, the URL for returned by the custom shortcode will be equal to the URL of the current page. Here's how you can use conditional HTML to test the current page's URL against the previous page URL:
[wpv-conditional if="( '[ts_get_adjacent_post_url previous='1']' ne '[wpv-post-url id='$current_page']' )"]Only show if there is a previous post in list[/wpv-conditional] [wpv-conditional if="( '[ts_get_adjacent_post_url previous='1']' eq '[wpv-post-url id='$current_page']' )"]Only show if there is not a previous post in list[/wpv-conditional]
Relevant Documentation:
https://toolset.com/forums/topic/display-wpv-post-next-link-and-wpv-post-previous-link-as-raw-html-link/#post-619757
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 6 years, 8 months ago.
Assisted by: Christian Cox.