How to Include One Tag While Excluding Another
-
I want to include in my sidebar posts that include a specific tag and exclude another one.
Quick background: I collect quotes on my site. They are all tagged “Quote.” However, some are too long for display in the sidebar. For these, I have included a “Long” tag, in addition to the “Quote” tag.
So the logic is that I want to include in the loop all posts that are tagged “Quote” but not tagged “Long.”
I tried the following code but it does not work. It does include the post that are tagged “Quote,” but it does not exclude posts that are tagged “Long”:
<?php query_posts('showposts=1&tag=Quote,-Long&orderby=rand'); if (have_posts()) : while (have_posts()) : the_post(); ?> <?php echo the_content(); ?> <?php endwhile; endif; ?> <?php wp_reset_query(); ?>
What am I missing here?
Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)
- The topic ‘How to Include One Tag While Excluding Another’ is closed to new replies.