Reputation: 898
how do i show the first post in full then the other posts just titles.
I've managed to strip some php code that generates the_content so i can just have the title displayed. Now i want the first post to show in full except for the others.
thanks.
edit: currently i have this default code to just loop through each post and show the title.
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="post-date"><?php the_time('F j, Y') ?></div>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
Upvotes: 1
Views: 655
Reputation: 3863
maybe try this...
<?php
$per_page=$paged<=1?9:10;
$i=0;
query_posts(array(
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $per_page,
) );
if (have_posts()) :
while (have_posts()) : the_post();
if ($paged<=1 && $i==0)
{ ?>
<!-- Loop that displays first post -->
<div class="post-date"><?php the_time('F j, Y') ?></div>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php the_content()); ?>
<?php } else { ?>
<!-- Loop that displays rest of the post -->
<div class="post-date"><?php the_time('F j, Y') ?></div>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php } $i++; endwhile; ?>
<?php next_posts_link(__('« Older Entries')) ?>
<?php previous_posts_link(__('Newer Entries »')) ?>
<?php endif; wp_reset_query(); ?>
The numbers at the top is what is offsetting it. $per_page=$paged<=1?9:10;
First page shows latest post in first loop '1', then the rest '9', and then on the following pages it displays '10' = <=1?9:10;
Hope this helps.
Upvotes: 0
Reputation: 4460
<?php $i=0; ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $i+=1; ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="post-date"><?php the_time('F j, Y') ?></div>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php if($i<2): the_excerpt(); ?>
...
Upvotes: 1