• Resolved katrinakvr

    (@katrinakvr)


    Hi Christopher,

    I’m having a devil of a time getting excerpts to display. Ideally I want them on the home page and the category pages.

    Do you have any hints??

    Thanks!
    Katrina

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author cberg

    (@cberg)

    Hi Katrina,

    please do the following.

    Log-in to your backend and navigate to Appearence -> Editor.

    Then select the Twenty Twelve Theme (right-top).

    Open the content.php of the Twenty Twelve Theme and search for the following code:

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

    Replace this with the follwing code:

    <div class="entry-summary">
    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->

    Please see the function reference, too:
    the_excerpt

    Btw: If you haven’t, you should create a child-theme where you do these changes because updates of the Twenty Twelve Theme can overwrite your changes.

    -> Child Themes

    I hope this was what you were looking for 🙂

    Kind regards,
    Christopher

    Thread Starter katrinakvr

    (@katrinakvr)

    Hi Christopher,

    Thank you very much for your help. Curiously, your suggested code is already in content.php. But, it looks like it might only being called when there is a search.

    Here is the whole bit:
    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class=”entry-summary”>
    <?php the_excerpt(); ?>
    </div><!– .entry-summary –>

    Many years ago I did programming, but I’m not really familiar with PHP, and I’m pretty much a newbie with WP.

    Thanks for the links too, I’ll see where they take me.

    Cheers,
    Katrina

    Theme Author cberg

    (@cberg)

    Hi Katrina,

    sorry, I was a bit in trouble this morning :/

    This code should work:
    <?php if ( is_search() || is_home() || is_category() ) : // Only display Excerpts for Search, Home and Category ?>

    Sorry again and kind regards,
    Christopher

    Thread Starter katrinakvr

    (@katrinakvr)

    Thanks very much Christopher, no apologies needed!

    This works great and your other links have pointed me in the direction to learn about this myself.

    Cheers,
    Katrina

    Thread Starter katrinakvr

    (@katrinakvr)

    Hi Christopher,

    I was having trouble with all posts that met the is search, home, category criteria being treated as if they had excerpts. But I fixed it without bothering you and got the “more” links prompts to match too. Here’s the code I ended up with:

    <div class=”entry-summary”>
    <?php if (( is_search() || is_home() || is_category() ) && has_excerpt()) : // Only display Excerpts for Search, Home and Category ?>
    <?php the_excerpt(); ?>
    “> MORE <span class=”meta-nav”>→</span> </div>
    <!– .entry-summary –>
    <?php else : ?>
    <div class=”entry-content”>
    <?php the_content( __( ‘MORE <span class=”meta-nav”>→</span>’, ‘twentytwelve’ ) ); ?>

    I have another question about the styling, but I’ll start a new thread for that.

    Thanks again,
    Katrina

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Post Excerpt Display’ is closed to new replies.