WordPress.org

Support

Support » Themes and Templates » Twenty Eleven – display excerpt in tag, category, and date archives

Twenty Eleven – display excerpt in tag, category, and date archives

  • Hi,
    I need the tag & date archives of this website to only display the excerpt instead of the entire text of the post. How do I alter the default templates to do this?

    (I have already created a “child theme” so I am not altering any of the Twenty Eleven templates.)

    Thank you!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Moderator Michael

    @alchymyth

    Forum Moderator

    try and edit content.php; find:

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

    change to:

    <?php if ( is_tag() || is_date() || is_search() ) : // Only display Excerpts for Tag Archive, Date Archive, and Search ?>

    http://codex.wordpress.org/Conditional_Tags

    (untested)

    This worked perfectly! Thank you!

    (Also added “is_category” and it worked great.)

    This worked great, thanks!

    Hi,
    Using this works fine except not for is_category.

    My category pages are still showing full entries, as per this link: http://www.realepicurean.com/category/recipes/

    Any ideas?

    Moderator Michael

    @alchymyth

    Forum Moderator

    what is your code in that line of content.php?

    <?php if ( is_tag() || is_date() || is_search() || is_category() ) : // Only display Excerpts for Search ?>

    Moderator Michael

    @alchymyth

    Forum Moderator

    nothing wrong with that code –

    possibly try to change it to:
    <?php if ( is_archive() || is_search() ) : // Only display Excerpts for Search ?>

    do you have any plugins that might possibly interfere?

    try to deactivate all plugins; if that helps, re-activate one after the other to find the trouble one.

    No joy. Must be missing something…

    realepicurean

    You want to change category pages to show excerpts not full posts yes?

    Me too – here is what worked for me

    Edit category.php (I’m using a twentyelevenchild theme)

    Change this around line 39
    get_template_part( 'content', get_post_format() );

    to this:

    ?>
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>

    This gives an excerpt and title which is a link to the full post.

    Good luck!

    Matthew Slyman

    @matthew_of_cambridge

    Thanks alchymyth! That Conditional_Tags page you recommended is excellent.

    Here’s my preferred option:
    <?php if ( !is_single() ) : // Only displays content for single posts. Displays excerpts for everything else. ?>

    Thank you bluejpro.
    Works great! 😀

    Great Matthew Slyman! That conditional ROCKS!!

    Great tips from Matthew Slyman and alchymyth ! I have been looking for this answer for the last several days. Thanks guys.
    However,I wonder if we could also put “Continue Reading …” link for each post on the Home Page, after the first image and the first paragraph of each post. If no image present at the beginning, it will only show the first paragraph.

    Actually I got the idea from this plugin http://wordpress.org/extend/plugins/auto-read-more-generator/

    Any help would be very appreciated.

    order matters–

    if i change line from

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

    to

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

    it breaks theme/crashes

    BUT if i change it to

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

    IT WORKS (excerpts on archive pages)

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Twenty Eleven – display excerpt in tag, category, and date archives’ is closed to new replies.