0

I am using the Twenty Eleven theme and need to show the full content of the latest post and then show the rest as summary. I'm looking for instructions/help on how to display, on the home page, the full post of the most recent article and then just the summary of the older the posts.

For Example (Post #5 being the newest & Post #1 being the oldest):

Post #5 (Full Article)

Post #4 (Summary)

Post #3 (Summary)

Post #2 (Summary)

Post #1 (Summary) <-- Next

Any ideas? Please help!

3 Answers 3

2

after creating a child theme for Twenty Eleven, copy content.php from the Twenty Eleven theme into your child theme to edit it;

find (line 35):

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>

change to:

    <?php if ( is_search() || is_paged() || $wp_query->current_post > 0 ) : // Only display Excerpts for Search, paginated pages, or any other then the first post ?>

then find this section:

    <div class="entry-content">
        <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?>

and change to:

    <div class="entry-content">
        <?php global $more; if( $wp_query->current_post == 0 && !is_paged() ) $more = 1; ?>
        <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?>
8
  • I am a newbie to WP. Can't I just modify either the index.php or content.php to get this done? Pls let me know. Thanks for your help.
    – user9464
    Oct 15, 2011 at 20:28
  • creating a child theme is - a: important - b: quite easy. of course you can edit whatever you like, however, in Twenty Eleven, index.php basically calls content.php for the output of the posts, so imho content.php is the template to edit.
    – Michael
    Oct 15, 2011 at 20:44
  • If I make the changes you mentioned above directly on the content.php, will it work? Also I don't see you have any function to show the "Excerpts". It has only the "the_content" function. Please advise.
    – user9464
    Oct 16, 2011 at 4:22
  • yes - it should work. i only posted the lines to be changed - the excerpt part is already in the original code of content.php
    – Michael
    Oct 16, 2011 at 13:31
  • Thanks, I will try the code and let you know. Also any idea on how to show the "featured image" on post listings on home page and for search also?
    – user9464
    Oct 16, 2011 at 14:00
0

or just create a page template using the following code, create a new page using this template and set as your homepage (of course you can throw in your own divs and classes and such :

<?php
/*

Template Name: HomePage

for showing the latest full post
and a list of older post excerpts

*/
?>

<?php get_header(); ?>

 <!-- show latest post -->

 <?php query_posts('showposts=1'); ?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <div class="lastest-post">



     <h2 class="pagetitle"><?php the_title(); ?></h2>

                        <?php the_content(); ?>

</div><!--close .latest-post -->

 <?php endwhile; endif; ?><!-- end lastest post -->


 <!-- show older post excerpts -->

<?php query_posts('showposts=5&offset=1'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="older-post">

         <h3 class="pagetitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
        <?php the_excerpt(); ?>

        </div><!--.older-post -->

<?php endwhile; endif; ?><!-- end past-entry -->

<?php get_sidebar(); ?>

<?php get_footer(); ?>
1
  • using the 'offset' parameter with a query is known to make pagination impossible. also, Twenty Eleven has a complex way of dealing with the sidebar in page templates, so there will be extra coding needed to get that right.
    – Michael
    Oct 15, 2011 at 20:47
-1

Look the file "content.php" in line 35: if ( is_search() ) : change by this if ( is_search() || is_home() ) : \o/

1
  • Will be overwritten during the next update. Useless.
    – fuxia
    Nov 5, 2012 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.