WordPress.org

Ready to get started?Download WordPress

Forums

How do I display excerpts of posts on my index page? (20 posts)

  1. thehealthyskeptic
    Member
    Posted 6 years ago #

    I'd like to display excerpts of posts rather than the full posts on my index page. How do I do that?

  2. boober
    Member
    Posted 6 years ago #

    look in your index.php file. replace
    <?php the_content(); ?>
    with
    <?php the_excerpt() ?>

  3. thehealthyskeptic
    Member
    Posted 6 years ago #

    Which index.php file? The one in my root directory only has this:

    '<?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
    ?>'

    In the index.php file within my theme, I was able to find the code you listed and change it to '<?php the_excerpt() ?>' but absolutely nothing changed. I still see the full-length posts on my index screen.

    How many lines of the post does an excerpt show?

  4. boober
    Member
    Posted 6 years ago #

    are you sure the change is being saved? its the index page of your theme, once youve made the change, leave the file, then go back into it to make sure what you changed is still there.
    unless you have really short posts, you should see a difference.

  5. thehealthyskeptic
    Member
    Posted 6 years ago #

    Thanks for your reply. I have definitely changed it, the change is definitely being saved, and yet the excerpts aren't appearing.

    Take a look: http://thehealthyskeptic.org

    ???

  6. boober
    Member
    Posted 6 years ago #

    are you sure youre changing the index file in the right theme folder? it would be in wp-content/themes/tarski/

  7. thehealthyskeptic
    Member
    Posted 6 years ago #

    Yep. That's the file. Here's the relevant section of code:

    '<div class="content">
    <?php the_excerpt(); ?>
    </div>'

    Could there be something in the theme that overrides the change?

  8. thehealthyskeptic
    Member
    Posted 6 years ago #

    Must be a theme-specific issue, because I switched to the default theme and changed "the_content" to "the_excerpt" in that theme and it worked just fine. Something in Tarski is preventing that change from taking effect. I've posted a message to the Tarski support forum, but if you have any ideas I'd love to hear them!

  9. boober
    Member
    Posted 6 years ago #

    its hard to tell without being able to look at the theme files.

  10. Len
    Member
    Posted 6 years ago #

    I just had a look at this theme. thehealthyskeptic, study your theme more closely. What do you see in index.php? I see this at the top ...

    <?php if(is_single() || is_page()) { // Single entries and pages ?>
    
    <-------code------------->
    
    <?php } else { ?>
    <?php include(TEMPLATEPATH.'/loop.php'); ?>
    
    <-----more code-------->

    What does that say? It says if we are on single.php or page.php DO THIS. In this case THIS being the_content otherwise (ELSE) call <?php include(TEMPLATEPATH.'/loop.php'); ?>

    The changes you want to make are in loop.php

  11. thehealthyskeptic
    Member
    Posted 6 years ago #

    LenK,

    Thanks for pointing that out. I'm still a novice with all of this, and on somewhat of a crash course here.

    I changed the reference in "loop.php" and that worked. However, my question now is whether there's some way of automatically inserting the <--more!--> code at the end of every post automatically so that the reader can click through to the full post?

    Thanks.

  12. haochi
    Member
    Posted 6 years ago #

    No, but I think this is what you want to do:

    Add after <?php the_excerpt(); ?> -
    <p><a href="<?php the_permalink() ?>">Continue to read the full post of "<?php the_title(); ?>" ...</a></p>

  13. Len
    Member
    Posted 6 years ago #

    I'm still a novice with all of this, and on somewhat of a crash course here.

    I can appreciate that. That's why I told you to study loop.php rather than give you a cut and paste answer so that you can learn and understand the logic behind it. :)

    way of automatically inserting the <--more!--> code at the end of every post automatically so that the reader can click through to the full post?

    Now you've lost me. If you're using the_content then yes but not if you're using the_excerpt. The way you had it originally will spit out the contents of the post and stop where the <--more--> tag is inserted.

    Or you can try haochi's suggestion. He's a smart cookie. ;)

  14. thehealthyskeptic
    Member
    Posted 6 years ago #

    Thank you both - that's exactly what I was looking for!

  15. charlesleo
    Member
    Posted 6 years ago #

    I'm trying to do the same thing here.

    I can add:

    <p>">Read More"<?php the_title(); ?>" ...</p>

    and it will link to the permalink.

    The problem I encounter is that EVERY post now has a "Read More..." link. Is it possible to set this to be conditional - only if a post is being cut-off/shortened by default?

    I get cut here:
    http://www.mightyfunk.com/2008/04/
    and:
    http://www.mightyfunk.com/category/photography/

    The reader wouldn't know that 'More' of the post existed.

    When they both should have a "Read More..." linking to a page like:
    http://www.mightyfunk.com/2008/04/photography-placeholder/

  16. charlesleo
    Member
    Posted 6 years ago #

    I need to add that I am just testing this system. I haven't put anything in the 'Excerpt' section - just in the 'Post.'

  17. alkalar
    Member
    Posted 5 years ago #

    I have a related problem. <!--more--> on the front page is working just fine, but when you click on the link, you get a 404 page.

    On the one example I have, the link is: ...blog address.../2008/10/02/watered-down-writing/#more-12. I looked in the files and the folder 2008 doesn't exist, let alone the rest of the address.

    The only thing I can think of is that I have a couple of options that are fighting with each other over where the full article belongs. I can edit the article just fine from the admin dashboard, so it's out there somewhere.

    Any ideas of where to look?

  18. meryl
    Member
    Posted 5 years ago #

    My blog uses excerpt and ends the excerpt with [...]

    I'd rather it end with "Read more blah blah". Right now, it has both as the link below shows you. I need to get rid of the useless [...]. Appreciate any pointers.

    http://www.meryl.net/section/blog/

    Would like to fix it on the home page too.
    http://www.meryl.net/

    Actually, I would like th blog page not to show excerpts and instead show the_content(). But whenever I use that code -- the paragraph formatting turns into a blob.

    I already have a big blob problem (lack of formatting). This one was not a blob at one point, but it is now.
    http://www.meryl.net/2009/01/7-traits-of-bad-twitter-follows/

    I do NOT use Word. I often write the post in Firefox 3.0 right in the editor. I read the paragraph posts and saw references to Tiny_MCE, but don't see how that affects this.

    Thank you in advance for any help. Golly -- it's so unreadble.

  19. meryl
    Member
    Posted 5 years ago #

    Here are screen shots...

    Poorly WordPress formatted post: http://twitpic.com/1eo26

    Correctly formatted WP post (except for image) http://twitpic.com/1eo2j

  20. meryl
    Member
    Posted 5 years ago #

    OK, I disabled the HTML-editor... and face editing over 2000 posts as it looks like I have to enter the paragraphs, too... or is there a faster way?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.