• the following will bring up posts from Category ID 6
    then display all the posts which also have category ID 7

    How can I display the posts associated with category ID 8,9,10 ect?

    below my current category…

    I’ve tried rewind posts, but that didnt seem to work.

    also Ideally I’d like to replace my <h2>Category<h2> with the current categoy name in the loop…if thats possible

    I’m not sure if this is clear

    <?php
     if (is_page('3') ) {
    $cat = array(6);
    } else {
    $cat = '';
    }
    
    $showposts = -1; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
       'category__in' => $cat,
       'showposts' => $showposts,
       'caller_get_posts' => $do_not_show_stickies
       );
    $my_query = new WP_Query($args); 
    
    ?>
    		<div id="colLeft">
    <h2>Category</h2>
    	<?php if( $my_query->have_posts() ) : ?>
    
    		<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
     		<?php if ( in_category('7') ) { ?>
    
    			 <div class="boxgrid thecombo">
    				<img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo get_post_meta($post->ID, "largethumb", $single = true); ?>&h=300&w=300&zc=1" alt="<?php the_title(); ?>" width="300" height="300" class="cover" />
    
    					<p><a href="<?php the_permalink() ?>" class="lightbox title"><?php the_title(); ?></a></p>
    
    					<p><a href="<?php the_permalink() ?>">Read more &raquo;</a></p>
    
    			</div>
      <?php } ?>
    
    		<?php endwhile; ?>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • Changing
    $cat = array(6);
    to
    $cat = array(6,7);
    and
    'category__in' => $cat,
    to
    'category__and' => $cat,
    would retrieve posts in category 6 AND 7.

    Not clear on what you are asking about “How can I display the posts associated with category ID 8,9,10 ”

Viewing 1 replies (of 1 total)

The topic ‘Displaying Multiple categories — Partially solved!’ is closed to new replies.