A
A
alex1nd2016-05-25 13:09:54
PHP
alex1nd, 2016-05-25 13:09:54

Posts differently in wordpress, how to modify the loop?

An example is on the main page www.lookatme.ru
and here is also similar severn-wp.ecko.me
a711b186b9f6.png
or change the cycle or do several,
it doesn’t work like that

<?php  
$postnum = 0;  
while (have_posts()) : the_post(); ?>  
   
<?php if ($postnum <= 2){ ?>  
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">  
  <div class="date"><span><?php the_time('M j') ?></span></div>  
    <h2>(<?php echo $postnum;?>)<a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>  
    <div class="post-image" style="text-align:center;">  
        <a href="<?php the_permalink() ?>"><img src="<?php bloginfo('template_directory' ); ?>/timthumb.php?src=<?php  echo catch_that_image(); ?>&amp;w=500&amp;h=200&amp;zc=1" alt="<?php the_title(); ?>" /></a>  
    </div>  
    <p><?php the_content('Read the rest of this entry &raquo;'); ?></p>  
    <p class="more"><a href="#">Read More</a></p>  
  </div>  
</div>  
   
<?php } else {  
<div <?php post_class( 'single ' . $end ); ?> id="post-<?php the_ID(); ?>">  
    <div class="post-content">  
        <h3><a href="<?php the_permalink() ?>">(<?php echo $postnum; ?>)<?php the_title(); ?></a> <?php edit_post_link('_', '', ''); ?></h3>  
        <p><?php the_excerpt( '' ); ?></p>  
        <p class="more"><a href="#">Read More ?</a></p>  
    </div>  
</div><!-- End post -->  
   
<?php }
    $postnum++;  
    endwhile;  
    ?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question