• Hi!

    I have a small problem with the loop of my index. I’m using this template:

    http://wpthemedesigner.com/demo/index.php?wptheme=The+RedMMOZine

    As you can see, is a magazine theme with an easy structure:

    New 1 (the latest, with a different css than other posts)
    and below, in 2 columns
    New 1 New 2
    New 3 New 4
    New 5 New 6

    The trouble is i dont want a duplicate New 1, in the latest and in the posts. I mean i want:

    New 1
    New 2 New 3
    New 4 New 5
    New 6 New 7

    I don’t know what i’ve done wrong in my loop, but this is my index.php (i’ve excluded a category as you can see):

    <!-- BEGIN content -->
    <div id="content">
    
    	<?php
    	if (have_posts()) : the_post();
    	?>
    	<?php
    	if (is_home()) { query_posts("cat=-6");
    	}
    	?>
    
    	<!-- begin latest post -->
    	<div class="latest post">
    
    		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    		<p class="details">
    		<?php the_time('j F Y') ?> por <?php the_author_posts_link(); ?> &nbsp;| &nbsp;<?php comments_popup_link('Sin comentarios', '1 Comentario', '% Comentarios'); ?>
    		</p>
    		<a href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?></a>
    		<?php the_excerpt(); ?>
    		<p class="bottom"><a class="continue" href="<?php the_permalink(); ?>">Leer + </a></p>
    	</div>
    	<!-- end latest post -->
    
    	<?php endif; ?>
    
    	<?php
    	if (have_posts()) :
    	while(have_posts()) : the_post();
    	?>
    
    	<!-- begin post -->
    	<div class="post">
    		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    		<p class="details">
    		<?php the_time('j F Y') ?> por <?php the_author_posts_link(); ?> &nbsp;| &nbsp;<?php comments_popup_link('Sin comentarios', '1 Comentario', '% Comentarios'); ?>
    		</p>
    		<a href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?></a>
    		<?php the_excerpt(); ?>
    		<p class="bottom"><a class="continue" href="<?php the_permalink(); ?>">Leer +</a>
    		</p>
      </div>
    	<!-- end post -->
    
    	<?php endwhile; ?>

    Can you help me with this??? Thanks a lot and sorry if i haven’t explained myself correctly…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try changing this:

    <?php
       if (is_home()) { query_posts("cat=-6");
       }
    ?>

    to this:

    <?php
       if (is_home()) { query_posts("cat=-6");
          $latestid = $post->ID;
       }
    ?>

    And this:

    <?php
       if (have_posts()) :
       while(have_posts()) : the_post();
    ?>

    to this:

    <?php
       if (have_posts()) :
       while(have_posts()) : the_post();
       if ($post->ID == $latestid) continue;
    ?>
    Thread Starter enviado

    (@enviado)

    Thanks mate!

    It worked but with a ‘but’. The (“cat=-6”) doesn’t work in Latest Post. It hasn’t any sense… i think i can ‘survive’ with your answer, but… any suggestion for excluding the category in the Latest Post?

    I thought your code was working except for the duplicate – sorry.

    See the Codex page The Loop, especially the section ‘Multiple Loops in Action’.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to config the loop in my index’ is closed to new replies.