Exclude posts containing a particular tag
-
Hi
I am fairly new to WP and PHP so please forgive my lack of knowledge; Bascailly I’ve been setting up template pages to show posts which have been tagged with certain tags;It looks like I’ve got working; however what I need to do now is the opposite; to exclude posts containing certain tags; I have paasted the current code which includes certain tagged posts here, can anyone suggest how to modify it to exclude them;
Thanks for your help
Darren<?php /* Template Name: Helens Posts */ get_header(); ?> <div id="content_box"> <div id="content" class="posts"> <?php $term = get_term_by('slug','helen', 'post_tag'); $args=array( 'tag__in' => array($term->term_id), 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <h2><?php the_title(); ?></h2> <h4><?php the_time('F jS, Y') ?><!-- by <?php the_author() ?> --> · <a>#comments"><?php comments_number('No Comments', '1 Comment', '% Comments'); ?></a> · <?php if (!is_attachment()) { the_category(', '); } ?> <?php edit_post_link('Edit', ' ·', ''); ?></h4> <div class="entry"> <?php the_content('<p>Read the rest of this entry »</p>'); ?> <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?> </div><?php if (!is_attachment()) { ?><p class="tagged"><strong>Tags:</strong> <?php the_tags('','·',''); ?></p><?php } ?> <div class="clear"></div> <?php endwhile; } wp_reset_query(); // Restore global post data stomped by the_post(). ?> </div> <?php get_sidebar(); ?> </div> <?php get_footer(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Exclude posts containing a particular tag’ is closed to new replies.