Related posts by tags except the specified tag
-
Hello
I m stuck and need help, so until now i m able to show related posts by
Tags.But i i want to exclude a tag from it EX:
i want show all related post that have similar tag and execlude the
tag (USA per exemple from the comparisonhere is the code that i m using
<?php $args = array(); $cats = array(); $categories = get_the_tags(); foreach($categories as $cat) $cats[] = $cat->term_id; $args['tag__in'] = $cats; $args['post__not_in'] = (array)$post->ID; $args['posts_per_page'] = 3; $args['orderby'] = 'rand'; $query = new WP_Query($args); while($query->have_posts() ) : $query->the_post(); ?> <div class="column"> <div class='inner'> <a href="<?php the_permalink();?>">
i hope i was clear thank you
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Related posts by tags except the specified tag’ is closed to new replies.