hi
I've entered this shortcode in elementor template for single "work" (custom post type):
[wpv-post-next-link format="%%LINK%%" link="Next Hand"]
It leads to the same post in all posts, and in the actual post it leads to - the button isn't seen at all.
you can see here:
enlace oculto
enlace oculto
enlace oculto
enlace oculto
in all the above, pressing "next hand" leads to the same post - enlace oculto - and in the "briefly" post the button isn't showing at all
thx!
Hi there
I expect the problem is that when using an Elementor template the context of the current post is lost to such Toolset shortcodes.
Can you try the same in a template made with Toolset?
I suspect it may work if you add the shortcode to an unassigned Content Template and then insert that template (via the wpv-post-body shortcode) into the Elementor template, rather than inserting the shortcode directly.
Hey Nigel
Still doesn't work.
I created an unassigned content template with the shortcode and called it "next shortcode".
Then I inserted the shortcode into the elementor single post templet like this:
[wpv-post-body view_template="next-shortcode"]
but the situation remains the same
Hi,
Thank you for sharing this update.
Can you please test if it makes any difference when the current post's ID is specified, through the 'item' attribute:
[wpv-post-body view_template="next-shortcode" item="[wpv-post-id]"]
In case, it still doesn't work, you're welcome to share temporary admin login details so that we can see exactly how the Elementor template is set up.
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
Thank you for sharing the access details.
For the 'next' and 'previous' post links, the published date is used for deciding the adjacent posts.
And if you check the published dates of your website's "Works" posts, there are just two groups based on the published dates.
( screenshot: enlace oculto )
a). 2 posts are published on 2022/08/01 at 8:12 am
b). The rest of the 38 posts are are published on 2022/08/01 at 8:04 am
( the exact same published dates suggest that these posts were imported )
For the 'next' and 'previous' post links to work correctly, you'll need to make sure that these posts have distinct published dates, so that they can follow an order.
I see, thanks Waqar.
I indeed changed the minute of publication hour in each post and now that works. But the question is, is there a way to make this work not according to time, but alphabetically, because in the future I will import posts via wp-all-import, which would make some posts import at the same minute and I don't want to go over manually and change dates all the time...
thanks!
You're welcome and glad I could help.
The Toolset's shortcodes for the next and previous links, use WordPress standard functions to get the adjacent posts.
To change the criteria to the post titles, you'll need to include some custom functions with relevant filters.
You'll find a good code snippet example in this forum reply:
https://wordpress.stackexchange.com/a/166933
function filter_next_post_sort($sort) {
$sort = "ORDER BY p.post_title ASC LIMIT 1";
return $sort;
}
function filter_next_post_where($where) {
global $post, $wpdb;
return $wpdb->prepare("WHERE p.post_title > '%s' AND p.post_type = '". get_post_type($post)."' AND p.post_status = 'publish'",$post->post_title);
}
function filter_previous_post_sort($sort) {
$sort = "ORDER BY p.post_title DESC LIMIT 1";
return $sort;
}
function filter_previous_post_where($where) {
global $post, $wpdb;
return $wpdb->prepare("WHERE p.post_title < '%s' AND p.post_type = '". get_post_type($post)."' AND p.post_status = 'publish'",$post->post_title);
}
add_filter('get_next_post_sort', 'filter_next_post_sort');
add_filter('get_next_post_where', 'filter_next_post_where');
add_filter('get_previous_post_sort', 'filter_previous_post_sort');
add_filter('get_previous_post_where', 'filter_previous_post_where');
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
My issue is resolved now. Thank you!