Skip Navigation

[Resolved] Previous / Next links do not fit to View order

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by matthiasK-3 3 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1919771

I created a view of a custom post type and set the ordering to "Last modified" and sort direction to "Descending" which works fine so far.
When opening a single post of this post type with a Toolset template the previous and next links do not show the last modified post but the standard order of wordpress.
Is there a possibility that these links show the same order as in the defined view?
I am using the Astra theme.

#1919979

Hi,

Thank you for contacting us and I'd be happy to assist.

There is no built-in feature available to change the order of the next/previous posts links, but you can use the WordPress filters to achieve this, as explained in this reply:
https://wordpress.stackexchange.com/a/73194

Example:


function wpse73190_adjacent_post_sort( $orderby )
{
    return "ORDER BY p.post_modified DESC LIMIT 1";
}
add_filter( 'get_previous_post_sort', 'wpse73190_adjacent_post_sort' );
add_filter( 'get_next_post_sort', 'wpse73190_adjacent_post_sort' );

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.

regards,
Waqar

#1920163

My issue is resolved now. Thank you!