Hi!
I want to create page that shows, on a loop, articles that belong to a category AND to a tag. For exemple, show all the articles that belong to the MOVIES category and are marked as DRAMA.
How can I do that?
Hi!
I want to create page that shows, on a loop, articles that belong to a category AND to a tag. For exemple, show all the articles that belong to the MOVIES category and are marked as DRAMA.
How can I do that?
Look at the Combining Parameters in the Codex article Template_Tags/query_posts for some examples.
[edit - oops that example doesn't have what you need so will keep looking]
Yeah, I noticed that. I even tried this query
<?php query_posts('cat=3&tag=13'); ?>
But it shows only the posts that belong to the category. I also tried only the "tag=13" query, and it shows nothing.
If anyone could help me... :)
Try this
<?php
query_posts('tag=drama');
if (have_posts()) : ?>
<?php while (have_posts()) : the_post();
if (in_category('3')) {
?>
/*
whatever you're displaying for your post here
*/
<?php } ?>
<?php endwhile; ?>It gives me an error -- about an unexpected $end (the "}", in this case). I tried this query below (for multiple loops) and it keeps showing nothing... If I delete the "cat" or "tag" info, it works. But both of them not... =/
<?php $my_query = new WP_Query(array('tag'=>drama,'cat'=>3,'showposts'=>4,'orderby'=>id,'order'=>DESC));
while ($my_query->have_posts()) : $my_query->the_post();?>See this post:
http://wordpress.org/support/topic/146199?replies=7
Your example <?php query_posts('cat=3&tag=13'); ?> won't work--it seems like right now you can't use BOTH cat= and tag= in query_posts.
BTW the code MichaelH posted above breaks for me too.
If your interested... I did write a plugin that supports a category and tag archive -- See http://wordpress.org/extend/plugins/tdo-tag-fixes/
I wrote it as an example how to support category and tag intersection.
MichaelH's theory does work, you're clearly just missing a close for the IF condition..
Thanks MichaelH - Took me 2 days to find this and it's finally working!
This topic has been closed to new replies.