• In previous WP versions, if you entered text in the optional “Excerpt” box, then the manually-entered excerpt would appear on index.php; if you left the “Excerpt” box blank, then the whole post would appear. I don’t want to use the <!–more–> tag, because I like the option of placing in the “Excerpt” box text that doesn’t necessarily appear in the actual post when viewed in its entirety … and I also don’t want to replace the_content() with the_excerpt(), because I’m not interested in having excerpts appear for all entries.

    In other words: it wasn’t broken until someone “fixed” it in the latest version. How do I get it back to how it was?

Viewing 8 replies - 1 through 8 (of 8 total)
  • I don’t remember ever such a feature as you described above – unless there are conditionals in the index that check for the presence of excerpt. So, maybe it was a different theme.

    Thread Starter jzahlaway

    (@jzahlaway)

    Worked in the “Kubrick” theme by default.

    So in 2.6, anything entered into the “Excerpt” box only appears on index.php if you have replaced the_content() with the_excerpt()? (Which means truncated excerpts for all other posts for which a specific “Excerpt” has not been entered?)

    Made perfect sense to me before that you got the full article unless you specifically entered an “Excerpt,” in which case you got said “Excerpt.” Is there an easy way to implement the desired behavior in 2.6?

    First: like Moshu, I have never heard of such a feature.

    Second: the first solution that comes to my head is to use a custom field (e.g. showexcerpt) and then check it in the loop. This obviously doesn’t get it back to the behavior you remember, but it’s the closest I can get you.

    Basically in your loop, in place of the_content you’d then say something like:

    if (!get_post_meta($post-<ID, 'showexcerpt', true)) {
      the_content()
    }
    else {
      the_excerpt()
    }

    What that should do, is get the post’s contents if you haven’t set a value for showexcerpt in the post’s custom fields. If you have, it’ll show the excerpt instead.

    Third: there *may* be a way to know if the user has changed the post’s excerpt, which would allow you to modify the code and get rid of the custom field altogether. I can’t think of what that way would be though.

    Thread Starter jzahlaway

    (@jzahlaway)

    The feature I’ve described is, in fact, an out-of-the-box feature found in previous editions.

    Fortunately, I still had a 2.3.3 site on my local drive, in which the following is contained in wp-content/index.php:

    <?php if($post->post_excerpt) :
     the_excerpt(); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Read the rest of <?php the_title(); ?>">Read the rest</a> »
    <?php else:
     the_content();
     endif;
     ?>

    I took that bit of code and replaced the following 2.6 code in wp-content/index.php:

    <div class="entry">
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    </div>

    Worked like a charm. Hope this helps someone else.

    Again, that is NOT a version specific feature – it is a theme-specific setup! So, you were wrong claiming that it was there is previous verisons and it disappeared now.
    It was there in one of your earlier themes, NOT in WP.

    As a sidenote: I hope you are NOT editing anything in a file at wp-content/index.php
    You should always edit your theme’s index file at
    wp_content/themes/yourtheme-name/index.php

    I hope this will protect others from being mislead by your wrong assumptions.

    Thread Starter jzahlaway

    (@jzahlaway)

    You should always edit your theme’s index file at
    wp_content/themes/yourtheme-name/index.php

    Yes, my bad; changes were made in wp-content/themes/[mytheme-name]/index.php.

    Again, that is NOT a version specific feature – it is a theme-specific setup! So, you were wrong claiming that it was there is previous verisons and it disappeared now.

    Forgive me if I wasn’t painfully explicit enough: It was a theme-specific setup that functioned as such right out of the box in the “default” theme that came with previous versions of WordPress … which it no longer does by default in 2.6. Apparently, the only way to get it to do so now is to monkey with the PHP code … which isn’t something we should assume the average user knows how to do. So, to the average, “default”-theme-using user who previously enjoyed using the “excerpt” functionality described in my original inquiry, said behavior has suddenly disappeared in the stock version of 2.6.

    I hope this will protect others from being mislead by your wrong assumptions.

    If you’re using the “default” theme that comes with 2.6, and you want your site to employ the “excerpt” behavior that the “default” theme employed in previous versions, the solution I’ve outlined above will accomplish that task, so long as you make the changes in wp-content/themes/[yourtheme-name]/index.php

    It was a theme-specific setup that functioned as such right out of the box in the “default” theme that came with previous versions of WordPress

    Not true. Period.
    I have ALL the WP versions on my local install since 1.2.1, all with the original default theme. None of them has that code.
    YOU edited that theme, just forgot about it…

    Thread Starter jzahlaway

    (@jzahlaway)

    YOU edited that theme, just forgot about it…

    If that is the case, then I stand corrected. My apologies.

    At any rate, our little shoving match notwithstanding, this should be a useful post for those who want to use the “Excerpt” box in such a way that “the_excerpt” displays instead of “the_content” only when a user enters text in said “Excerpt” box.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Display custom Excerpt on some–not all!–posts.’ is closed to new replies.