In the “You might also like” section on blog posts, how do I make it so posts in specific categories don’t show up in that list?
Hey donnaschilder,
Can you give us more context on this? so we can accurately provide an answer to it.
Best regards,
Nikko
Hi Nikko –
So the “You might also like” section is below and part of the Enfold theme. I want to exclude certain category posts from showing up here but can’t find anywhere to do that. For example, if I have Categories such as “Category 1”, “Category 2”, and “Category 3”, how do I make it show all posts associated with “Category 3” do not show in the “You might also like” articles?
Hi donnaschilder,
I apologize for the delayed response.
The “You might also like” section is not actually based on categories but based on tags, you can find its query in wp-content > themes > enfold > includes > related-posts.php (line 77-84):
$my_query = get_posts(
array(
'tag__in' => $tag_ids,
'post_type' => get_post_type($this_id),
'showposts'=>$postcount, 'ignore_sticky_posts'=>1,
'orderby'=>'rand',
'post__not_in' => array($this_id))
);
based on what WordPress Codex describes in https://developer.wordpress.org/reference/functions/get_posts/
You can add another argument which is category, however I may need enough context to give the exact code that you need, since you may have multiple categories and if you only have a single category for example the current post is category 1 should it show just category 1 or show all categories except for category 3? and if you have a single category 3 in your current post which related post should it show?
Best regards,
Nikko