category__and example
-
I am having trouble using the category__and parameter within query_posts() and am looking for some help with my code. The template I’m editing is category.php (based on archive.php). Here is what I have so far.
<?php get_header(); query_posts(array('showposts' => 1, 'category__and' => array(2,6))); if (have_posts()) : ?> <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> <?php /* If this is a category archive */ if (is_category()) { ?> <h2 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Category</h2> <?php } ?> <?php while (have_posts()) : the_post(); ?> <div <?php post_class() ?>> <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>""><?php the_title(); ?></a></h3> <?php the_content() ?> </div> <?php endwhile; ?> <?php else : printf("<h2 class='center'>Sorry, but there aren't any posts in the %s category yet.</h2>", single_cat_title('',false)); get_search_form(); endif; get_sidebar(); get_footer(); ?>
Instead of seeing the one post that is part of both category 2 and 6, I see “Sorry, but there aren’t any posts in the category yet.”
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘category__and example’ is closed to new replies.