Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Loop issues. WordPress

  • SOLVED

Ok so here's what I have: Two loops; One loop in the main column that displays latest posts except the ones from the category which is displayed in the sidebar.

I want to divide the loop in the main column into two, the first displaying the one latest post with a large thumbnail, and the second all the rest 9 latest posts with a smaller thumbnail.

Like nerve.com

Answers (4)

2011-01-14

Baki Goxhaj answers:

Ready for it: banago [at] gmail [dot] com


Baki Goxhaj comments:

Here goes the code:

<code>
<?php $i = 1; ?>
<?php $my_query = new WP_Query('showposts=10');
while ($my_query->have_posts()) : $my_query->the_post(); ?>

<?php if ( $i == 1 ) { ?>

//Big thumb and other staff goes here

<?php } elseif ( $i > 1 ) { ?>

//Other posts go here

<?php } ?>

<?php $i=$i+1; ?>

<?php endwhile; ?>

2011-01-14

S├ębastien | French WordpressDesigner answers:

No problem
Use query_post : [[LINK href="http://codex.wordpress.org/Function_Reference/query_posts"]]http://codex.wordpress.org/Function_Reference/query_posts[[/LINK]]

Do you want i write your code ?

2011-01-14

Ali Hussain answers:

<?php
/* Start non-duplicates */
function post_strip($where) {
global $myPosts, $wpdb;
$where .= " AND $wpdb->posts.ID not in($myPosts) ";
return $where;
}
?>
<?php
global $myPosts;
$myPosts = '';
?>


<!-- Loop 1 main post-->
<?php
$my_query = new WP_Query();
$my_query->query('showposts=1&cat=872')/*Put in number of posts to show and category*/;
if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>


<div>
<h2 class="post-title"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
<?php get_the_image( array(
'meta_key' => 'feature_img',
'width' => '280',
'height' => '160',
'image_class' => 'aligncenter' )
); ?>

<a href="<?php echo get_post_meta($post->ID, 'story-link', true); ?>">Visit</a>

<?php the_excerpt_reloaded(20, '', 'content', FALSE, '', FALSE, 2, TRUE); ?>

<br />
<a href="<?php the_permalink() ?>">Read more</a>


</div><!--//post-->
<?php endwhile; endif; ?>


you will need the "get-the-image" plugin From Justin

For the Second Loop
<?php
query_posts( array(
'cat' => 871,
'showposts' => 9,
'offset' => 0,
)
);
while ( have_posts() ) : the_post();
?>
<div class="post linking">
<div class="artic">
<h2 class="post-title"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
<?php get_the_image( array(
'meta_key' => 'feature_img',
'width' => '280',
'height' => '150',
'image_class' => 'aligncenter' )
); ?>

<a href="<?php echo get_post_meta($post->ID, 'story-link', true); ?>">Visit</a>

<?php the_excerpt_reloaded(20, '', 'content', FALSE, '', FALSE, 2, TRUE); ?>

<br /><a href="<?php the_permalink() ?>">Read more</a>

</div><!--//post-->
<?php endwhile; ?>


Yes with the code you can change your styling + post image sizes.
I have added a no-duplicate query to it so post may not repeat incase you wish not to use a specific category

Can be customized to even more depth, if i could had the exact template you wish to modify

2011-01-14

Utkarsh Kukreti answers:

Could you post the current loop code?