WordPress.org

Ready to get started?Download WordPress

Forums

Need one full article and the rest excerpts (8 posts)

  1. kicker
    Member
    Posted 1 year ago #

    I need to have the newest article full and all the rest as excerpts.
    I found a little on this but it was from 2007 and it seems too complicated. There must be some simple way of doing this?
    Thanx
    Kicker

  2. alanchrishughes
    Member
    Posted 1 year ago #

    To pull the most recent article (full content).

    <?php query_posts('orderby=asc&posts_per_page=10' ); ?>
    
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <a>" rel="bookmark" class="title">
    <?php the_title(); ?>
    </a>
    <?php the_content(); ?>
    
    <?php endwhile; ?>
    <?php endif; ?>
    
    Then to pull 10 of the most recent posts with just excerpts
    
    <?php query_posts('orderby=asc&posts_per_page=10' ); ?>
    
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <a>" rel="bookmark" class="title">
    <div>
    <?php the_title(); ?>
    <?php the_excerpt(); ?>
    </div>
    </a>
    
    <?php endwhile; ?>
    <?php endif; ?>
  3. alanchrishughes
    Member
    Posted 1 year ago #

    For some reason its not letting me post this in the 'code' blocks.

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    one possibility:

    <?php while( have_posts() ) : the_post(); //start of loop// ?>
    
    ...
    
    <?php
    if( $wp_query->current_post == 0 ) :
      the_content();
    else :
      the_excerpt();
    endif;
    ?>
    
    ...
    
    <?php endwhile; //end of loop// ?>
  5. kicker
    Member
    Posted 1 year ago #

    Cool and thanx. But where does that code go?

    What are code blocks?

    I thought this was built in to WP, but I guess it was built in to the last theme I used. A box that said something like HOW MANY FULL POSTS BEFORE EXCERPTS. That sure was easy! :)

  6. alanchrishughes
    Member
    Posted 1 year ago #

    Sorry, by code blocks I just meant on this messageboard, like the gray box alcyymyth got to work above there, and I think an admin must have fixed mine.

    The code will go in your index.php file, but if you aren't really familiar with coding I wouldn't suggest trying it yourself.

  7. kicker
    Member
    Posted 1 year ago #

    It all seems such a simple and useful option. Is there not a plugin for this kind of thing. I used HEADWAY as my last theme and it was part of that theme.

  8. alanchrishughes
    Member
    Posted 1 year ago #

    There are so many different needs and designs to meet those needs that it isn't always useful.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.