-
AuthorPosts
-
March 8, 2020 at 7:35 pm #1191298
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?
-
This topic was modified 5 years, 8 months ago by
donnaschilder.
March 9, 2020 at 5:14 pm #1191583Hey donnaschilder,
Can you give us more context on this? so we can accurately provide an answer to it.
Best regards,
NikkoMarch 10, 2020 at 12:20 am #1191665Hi 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?
March 12, 2020 at 4:25 pm #1192667Hi 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 -
This topic was modified 5 years, 8 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.
