• Resolved wealthed

    (@wealthed)


    Hi I am using the Therapy theme, I would like the newest post to display in full on the homepage but every post after that I would like to display only the excerpt I searched the forums and found that I could replace my the_content area with <?php if (!i) the_content(); else the_excerpt(); i=1; ?> to accomplish this but that gave me an error. Here is what the current the_content section looks like in my themes index.php:

    <?php if ( get_option(‘woo_content_home’) == “true” )
    the_content(‘[…]’); else the_excerpt(); ?>

    Thanks in advance!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator t-p

    (@t-p)

    A new pugin called “Ultimate Post Type Manager” came out today. See if it can do what you want

    Thread Starter wealthed

    (@wealthed)

    Not really looking for a plugin here since I’m already using a plugin to allow my excerpts to contain html writeup, just looking for a very simple one line modification in index.php to make it so that only the excerpt is shown on all the posts except for the very newest one.

    Thanks for the reply though!

    Just add a counter inside the loop, this could be in index.php or loop.php, not one line but not to many!

    <?php while ( have_posts() ) : the_post(); ?>
    <?php /* Increment the Counter */ ?>
    <?php $counter++; ?>

    Then in the content div where you will find the_content()

    <?php /* Conditional Output */ ?>
    <?php if($counter==1 : ?>
       <?php the_content(); ?>
    <?php else: ?>
      <?php the_excerpt(); ?>
    <?php endif; ?>

    HTH

    David

    Thread Starter wealthed

    (@wealthed)

    Thank you David!!!

    I was getting an error at first when I replaced the_content then I just added this line

    <?php $counter++; ?>

    under <?php endif; ?>

    and now it is working perfectly, thank you so much!

    Hi,
    Great, could you mark this as resolved please.

    For reference and anyone else that might find this topic in a search.
    I can see the error in my code, missing paranthasis.

    <?php if($counter==1 : ?>
    Should be
    <?php if($counter==1) : ?>

    This would still work with the $counter just inside the loop, if you add it after the endif, it would not be set until after the first loop, so it would be false (zero) in the first loop and the second would be ‘1’.

    The original code was adapted from code I have to add striped post titles, and it could be changed to make it easier.

    <?php /* Conditional output flag set after first post */ ?>
    <?php if($showexcerpt) : ?>
       <?php the_excerpt(); ?>
    <?php else: ?>
      <?php the_content(); ?>
    <?php endif; ?>
    <?php $showexcerpt=true; ?>

    HTH

    David

    Thank you! This worked great.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Full article for first post excerpts for the rest?’ is closed to new replies.