Hello,
would it be possible to exclude posts that are tagged with a certain tag from the related posts at the bottom of each blog post? (the “You might also like” posts)
Thank you for your help.
Hi,
Open includes/related-posts.php and look for lines 44-51:
$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))
);
Replace them by this:
$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),
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => array('_YOUR_UNDESIRED_TAG_'),
'operator' => 'NOT IN'
)
)
));
Change _YOUR_UNDESIRED_TAG_ by the tag you want to exclude.
Regards,
Josue
Thank you!!