WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Eleven - display excerpt in tag, category, and date archives (15 posts)

  1. kalanit74
    Member
    Posted 2 years ago #

    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!

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    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)

  3. kalanit74
    Member
    Posted 2 years ago #

    This worked perfectly! Thank you!

    (Also added "is_category" and it worked great.)

  4. bartsurminski
    Member
    Posted 2 years ago #

    This worked great, thanks!

  5. realepicurean
    Member
    Posted 2 years ago #

    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?

  6. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

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

  7. realepicurean
    Member
    Posted 2 years ago #

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

  8. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    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.

  9. realepicurean
    Member
    Posted 2 years ago #

    No joy. Must be missing something...

  10. bluejpro
    Member
    Posted 2 years ago #

    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!

  11. Matthew Slyman
    Member
    Posted 2 years ago #

    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. ?>

  12. fbozo
    Member
    Posted 2 years ago #

    Thank you bluejpro.
    Works great! :D

  13. David DWQ
    Member
    Posted 2 years ago #

    Great Matthew Slyman! That conditional ROCKS!!

  14. pribadi
    Member
    Posted 2 years ago #

    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.

  15. opensourcescribe
    Member
    Posted 2 years ago #

    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)

Topic Closed

This topic has been closed to new replies.

About this Topic