next/previous post links for specific category when post belongs to multiple categories

did you search around the functions get_adjacent_post() ? A long time ago, I made a Woocommerce plugin (an old outdated Woocommerce product navigation on the repo) that use it in the same case and it used to work. The class I created, use a fallback function to get all ids to exclude. Hope it helps … Read more

get_adjacent_post – in same term not working

The arguments for get_adjacent_post is not formatted correctly. $excluded_terms needs to be either a string or an array. Also be careful with the category. If ‘portcats’ is a category name and not a taxonomy, that won’t work. This is looking for posts that are in the same ‘portcats’ taxomony with certain terms in ‘portcats’ excluded. … Read more

Include scheduled ( future ) posts in WordPress post navigation ( previous_post_link, next_post_link )

You can do this by using the get_{$adjacent}_post_where filter. Basically all we are doing is replacing the part of the query that says “find published posts” with “find published or future posts”. /** * Amend the ‘WHERE’ clause in the SQL query to find an adjacent post * * @param required string $where The default … Read more

altering %title

Unfortunately, your logic doesn’t quite work out. The reason is because the order of operations, just like math, works inside to outside. So, your short_title() function is running with just passing the string %title, which then returns, I assume, the same string because that string meets your requirements. Then it passes %title onto previous_post_link and … Read more

Get previous/next post from (specific) category

When in_same_term parameter in get_next_post() / get_previous_post() function is set to TRUE, a post is selected from any category assigned to the current post. As you wrote, you can not use the exclude parameter in this case. Using the get_{$adjacent}_post_where filter, you can skip product in the category list, which you are looking for posts. … Read more