Support » Plugins » Add exception for specific tag

  • I’m using this piece of code to generate Related Posts by looking at the tags of posts. The problem is I have use a tag named featured (id=795) in order for a post to show up in a slideshow. So posts are showing up as related because of that matching Featured tag, even though they are not alike at all.

    So is there an easy to to exclude the tag “featured” in this code?

    <?php $tags = get_the_tags(); ?>
    <?php if($tags): ?>
    <?php $related = get_related_posts($post->ID, $tags); ?>
    <?php if($related->have_posts() && $related->found_posts >= 3 && get_option('pyre_related') == 'On'): ?>

    I am guessing there needs to be a tag__not_in or something similar included but I just don’t know PHP well enough to know the syntax.

Viewing 1 replies (of 1 total)
  • I found the answer. the get_related_posts function was found in the functions.php file where I had to edit the code to exclude the id of the tag.

    $args = wp_parse_args($args, array(
    		'showposts' => 4,
    		'post_type' => $post_types,
    		'post__not_in' => array($post_id),
    		'tag__in' => $tagsA,
    		'tag__not_in' => 795,
    		'ignore_sticky_posts' => 1,
Viewing 1 replies (of 1 total)
  • The topic ‘Add exception for specific tag’ is closed to new replies.