• I have this code in my index file:

    <?php $my_query = new WP_Query('category_name=photos&amp;showposts=1');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID;?>
    
    <div id="featuredphoto">
    <?php echo do_shortcode('[gallery]'); ?>
    <h2>&raquo; <?php the_title(); ?></h2>
    <div class="photoentry">
    <?php the_excerpt(); ?>
    </div>
    </div>
    
      <?php endwhile; ?>
        <!-- Do other stuff... -->
      <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
     <?php if ( in_category('41') ) { ?>
    
    <div id="gallerypost">
    <?php echo do_shortcode('[gallery]'); ?>
    <h2>&raquo; <?php the_title(); ?></h2>
    <div class="photoentry">
    <?php the_excerpt(); ?>
    </div>
    </div>
    
     <div class="clear"> </div>
    
     <?php } else { ?>
    
     <!-- If the post is in the category we want to exclude, we simply pass to the next post. -->
    
    	<?php $custom_fields = get_post_custom(); //custom fields ?>
    
    	<?php if (isset($custom_fields["BX_post_type"]) &amp;&amp; $custom_fields["BX_post_type"][0] == "mini") { ?>
    
    	<hr class="low" />
    
    	<div class="minientry">
    
    		<p>
    		<a href="<?php the_permalink(); ?>" title="Permalink"><?php the_time('M j, \'y') ?></a> &raquo; <?php echo BX_remove_p($post->post_content); ?>
    		<?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'commentlink'); ?>
       		</p>
    
    	</div>
    
    	<hr class="low" />
    
    	<?php } else { ?>
    
    	<div class="entry">
    
    		<h2><a href="<?php the_permalink() ?>" title="Permalink"><?php the_title(); ?></a></h2>
    
    <?php the_content('Read More &raquo;'); ?>
    
        <p class="post-tags">
          <?php if (function_exists('the_tags')) the_tags('Tags: ', ', ', '<br />'); ?>
        </p>
    
    		<p class="info"><?php if ($post->post_excerpt != "") { ?><a href="<?php the_permalink() ?>" class="more">Continue Reading</a><?php } ?>
       		<?php comments_popup_link('Add comment', '1 comment', '% comments', 'commentlink', ''); ?>
       		<em class="date"><?php the_time('F jS, Y') ?><!-- at <?php the_time('h:ia')  ?>--></em>
       		<!--<em class="author"><?php the_author(); ?></em>-->
       		<?php edit_post_link('Edit','<span class="editlink">','</span>'); ?>
       		</p>
    
    	</div>
    
    <!--
    <?php trackback_rdf(); ?>
    -->
    
    	<?php } ?>
    
     <?php } ?>
    
    <?php endwhile; ?>
    
    	<p><!-- this is ugly -->
    	<span class="next"><?php previous_posts_link('Next Posts') ?></span>
    	<span class="previous"><?php next_posts_link('Previous Posts') ?></span>
    	</p>
    
    <?php else : ?>
    
    	<h2>Not Found</h2>
    	<p>Sorry, but you are looking for something that isn't here.</p>
    
    <?php endif; ?>

    and i wanna get 2 different category posts to show up under the first post then have the rest of the posts go as normal under that. how can i do it?

Viewing 1 replies (of 1 total)
  • Hi

    You already have a custom loop for the first post.

    Set up a custom loop for the category posts, following that first loop.

    Then you need to exclude the posts that have already displayed from appearing again in the main loop. How you do that depends on how you are selecting the featured post and the category posts. It looks like what needs to happen is to save the post ID codes of the 3 posts preceding the main post, and then exclude those post ID’s from the main query loop using a query_posts statement preceding the main loop
    http://codex.wordpress.org/Template_Tags/query_posts

Viewing 1 replies (of 1 total)
  • The topic ‘How to get category posts under first post?’ is closed to new replies.