WordPress.org

Ready to get started?Download WordPress

Forums

Front page - Excerpt (25 posts)

  1. lokust
    Member
    Posted 9 years ago #

    :: originally posted in feedback - perhaps more appropriate here.

    Is it possible to publish just post Title and Excerpt on front page instead of the full body of the text?

    By clicking on Title - the user can check the full text for the post.

    Can this presently be done or would it require some php tweakery?

    Thanks,

    Al

  2. Kafkaesqui

    Posted 9 years ago #

    Yep. Yep and yep (on the tweakery -- nut not much).

    http://wordpress.org/support/topic.php?id=20906#post-119139

  3. lokust
    Member
    Posted 9 years ago #

    Just tried that (wordpress 1.5)

    Found: <?php the_content(); ?> in wp.php and changed it to:

    <?php if($single) { ?>
    <?php the_content(); ?>
    <?php } else { ?>
    <?php the_excerpt(); ?>
    <?php } ?>

    Wrote the article in advanced editing with an excerpt and it still displays the full story!

  4. Kafkaesqui

    Posted 9 years ago #

    For 1.5 you could also try:

    <?php if(is_single()) { ?>
    <?php the_content(); ?>
    <?php } else { ?>
    <?php the_excerpt(); ?>
    <?php } ?>

  5. lokust
    Member
    Posted 9 years ago #

    you're a star !
    I made the edit in index.php - works!
    Thanks

  6. jzahlaway
    Member
    Posted 9 years ago #

    I followed the suggestion here to successfully end up with a front page that publishes excerpts ... but not the way I was hoping it would.

    I would like full entries to appear on the homepage for all entries for which the excerpt block was left blank, and for excerpts to appear only for entries for which an excerpt was entered during post creation. Seems like this should be the default function ... but, instead, I now have excerpts only for ALL entries.

    Help?

  7. tdw
    Member
    Posted 9 years ago #

    If the posthas an excerpt display the excerpt, else display the content.

    Something like the following should work:

    <?php if($post->post_excerpt) :
    the_excerpt();
    else:
    the_content();
    endif;
    ?>

    or as a one-liner:
    <?php ($post->post_excerpt) ? the_excerpt() : the_content(); ?>

  8. jzahlaway
    Member
    Posted 9 years ago #

    Thanks, TDW. That's great.
    Any idea how/where I can add something that'll place at the end of the excerpt a link to the full entry?

  9. jzahlaway
    Member
    Posted 9 years ago #

    I answered my own question ... sorta.

    This gives me a link to the full entry that follows the excerpt:
    <?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;
    ?>

    However, it places said link on its own line, with a break between the excerpt and the link. Any idea how to get the link to remain inline with the final line of the excerpt itself?

  10. Lorelle
    Member
    Posted 9 years ago #

    I'm not sure if this helps, but do you have the <!--more--> placed in your post with a line above it or on the line that you want the excerpt to end?

    If you aren't using the "more" quick tag, and using an actual excerpt, check to see if there is a line break at the end of the excerpt.

    That might be the problem.

  11. jzahlaway
    Member
    Posted 9 years ago #

    Not using a <!--more--> tag; I hacked in a "Read the rest" link.
    No line break at the end of excerpt.

  12. tdw
    Member
    Posted 9 years ago #

    the_excerpt() comes back already filtered so to get your link appearing in the same paragraph you need to format the excerpt yourself:

    <?php if($post->post_excerpt) :
    $output = $post->post_excerpt();
    $output .= ' <a href="'.get_permalink().'" rel="bookmark" title="Read the rest of '.the_title().'">Read the rest-></a>';
    echo apply_filters('the_excerpt',$output);
    else:
    the_content();
    endif;
    ?>

  13. yukie
    Member
    Posted 9 years ago #

    just two things.
    first, I think
    $output = $post->post_excerpt();
    should look like
    $output = $post->post_excerpt;

    second, the title="Read the rest of '.the_title().'" part seems to be causing some problems. The post title appears again as part of the post content. Removing the call to the_title( ) solves the problem. I'm not sure why this is though. Is it a bug in apply_filters?

  14. Kafkaesqui

    Posted 9 years ago #

    Change

    the_title()

    to

    the_title("","",false)

  15. yukie
    Member
    Posted 9 years ago #

    thank you.

  16. fxchain
    Member
    Posted 9 years ago #

    I have permalink turned on, and I think it causes the excerpt to display even if I am looking at a particular post. None of the example above work for my WP1.5.

    I always see the_excerpt(); and never the_content();. Even if I click on one post.

    http://www.isp-blog.com

    Help

  17. fxchain
    Member
    Posted 9 years ago #

    Got it:

    <?php if(is_single()) {
    the_content();
    } else {
    the_excerpt();
    } ?>

  18. tom_de_schlong
    Member
    Posted 9 years ago #

    Just to make it easier for people coming in off of search engines (Like me). This is the final code you need

    <?php if ($post->post_excerpt) :
    $output = $output = $post->post_excerpt;
    $output .= ' <a href="'.get_permalink().'" rel="bookmark" title="Read the rest of '.the_title("","",false).'">Continue reading...</a>';
    echo apply_filters('the_excerpt',$output);
    else:
    the_content();
    endif;
    ?>

    Hope this helps

    T.Willmot

  19. herb37
    Member
    Posted 8 years ago #

    Please
    and in which file I have to add or change this code?
    Thx in advance from Germany

  20. tom_de_schlong
    Member
    Posted 8 years ago #

    You need to change the main index.php file in your main theme directory

  21. saichan
    Member
    Posted 8 years ago #

    hi, sorry, i'm a bit lost here...i see the_content() in my post.php and page.php files, but not index.php.

    which one do i change?

    thanks

  22. winterwish
    Member
    Posted 8 years ago #

    post.php i believe

  23. TigressWoods
    Member
    Posted 8 years ago #

    Thanks for all the information here. Is there a way to exclude a specific category from the excerpts?

  24. TigressWoods
    Member
    Posted 8 years ago #

    anyone?

  25. Businessman
    Member
    Posted 7 years ago #

    Superb thread - helped loads just now. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags