I have posts with two categories, for example, 1st post is in category "product" and "shoes", 2nd is in category "product" and "shirts", 3rd is in category "product" and "sport clothes"... So, posts have one mutual category ("product" in this example), and one more specific category.
I tried to get previous/next post with:
$next_post = get_next_post( true );
$previous_post = get_previous_post( true );
But then, for example on 2nd post I have 1st and 3rd post as previous/next posts, because they have one mutual category "product". I would like that on post about shirts I have other posts only which are in shirts category. I tried to exclude category "product" by it's ID like this:
$next_post = get_next_post( true, '5', category ); // 5 is ID of "product" category
$previous_post = get_previous_post( true, '5', category ); // 5 is ID of "product" category
But then I have no previous/next posts, because posts in "shirts" category are also in "product" category and function above says to exclude posts from that category.
Is there any way to do opposite, just to include posts which have one specific category?