Return to Snippet

Revision: 15697
at July 15, 2009 02:56 by crs


Updated Code
<?php $my_query = new WP_Query('cat=10&showposts=4'); ?>
<?php $count = 0; ?>  
<?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
<?php $count++; ?>  
    
	<?php if ($count == 1) : ?>  
		<div id="featured">
		  <div class="span-24 last" id="details">HTML Ipsum Presents</div>
		  <!-- end details -->
	          <h2 class="clear"><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2>
		  <p class="clear"><?php the_content('read more...'); ?></p>
		</div>
		<hr/>
	<?php elseif ($count == 4) : ?>  
		<div class="span-8 last">
		  <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
		  <p class="clear"><?php the_content('read more...'); ?></p>
		</div>
	<?php else : ?>  
		<div class="span-8 border">
		  <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
		  <p class="clear"><?php the_content('read more...'); ?></p>
		</div>
	<?php endif; ?>

<?php endwhile; ?>

Revision: 15696
at July 15, 2009 02:55 by crs


Updated Code
<?php $my_query = new WP_Query('cat=10&showposts=4'); ?>
<?php $count = 0; ?>  
<?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
<?php $count++; ?>  
    
	<?php if ($count == 1) : ?>  
		<div id="featured">
			<div class="span-24 last" id="details">HTML Ipsum Presents</div>
			<!-- end details -->
			<h2 class="clear"><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2>
			<p class="clear"><?php the_content('read more...'); ?></p>
		</div>
		<hr/>
	<?php elseif ($count == 4) : ?>  
		<div class="span-8 last">
		<h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
		<p class="clear"><?php the_content('read more...'); ?></p>
		</div>
	<?php else : ?>  
		<div class="span-8 border">
		<h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
		<p class="clear"><?php the_content('read more...'); ?></p>
		</div>
	<?php endif; ?>

<?php endwhile; ?>

Revision: 15695
at July 14, 2009 02:48 by crs


Updated Code
<?php $my_query = new WP_Query('cat=10&showposts=4'); ?>
<?php $count = 0; ?>  
<?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
<?php $count++; ?>  
    
	<?php if ($count == 1) : ?>  
		<div id="featured">
			<div class="span-24 last" id="details">HTML Ipsum Presents</div>
			<!-- end details -->
			<h2 class="clear"><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2>
			<p class="clear"><?php the_content('διαβά��ε �ε�ι����ε�α...'); ?></p>
		</div>
		<hr/>
	<?php elseif ($count == 4) : ?>  
		<div class="span-8 last">
		<h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
		<p class="clear"><?php the_content('διαβά��ε �ε�ι����ε�α...'); ?></p>
		</div>
	<?php else : ?>  
		<div class="span-8 border">
		<h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
		<p class="clear"><?php the_content('διαβά��ε �ε�ι����ε�α...'); ?></p>
		</div>
	<?php endif; ?>

<?php endwhile; ?>

Revision: 15694
at July 14, 2009 02:40 by crs


Initial Code
<?php $my_query = new WP_Query('cat=10&showposts=4'); ?>
<?php $count = 0; ?>  
<?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
<?php $count++; ?>  
    
	<?php if ($count == 1) : ?>  
		<div id="featured">
			<div class="span-24 last" id="details">HTML Ipsum Presents</div>
			<!-- end details -->
			<h2 class="clear"><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2>
			<p class="clear"><?php the_content('διαβάστε περισσότερα...'); ?></p>
		</div>
		<hr/>
	<?php elseif ($count == 4) : ?>  
		<div class="span-8 last">
		<h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
		<p class="clear"><?php the_content('διαβάστε περισσότερα...'); ?></p>
		</div>
	<?php else : ?>  
		<div class="span-8 border">
		<h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>
		<p class="clear"><?php the_content('διαβάστε περισσότερα...'); ?></p>
		</div>
	<?php endif; ?>

<?php endwhile; ?>

Initial URL

                                

Initial Description
Using this loop variation you can style differently the first and the last post of a loop, or whatever post you like, as lond as you add a new elseif with the number of the post you desire.

Initial Title
Wordpress Loop, Style displayed posts differently

Initial Tags
wordpress

Initial Language
PHP