WordPress.org

Ready to get started?Download WordPress

Forums

Only display excerpt (8 posts)

  1. stravaiger
    Member
    Posted 10 years ago #

    Is it possible to only have the excerpts displayed as links to the main text of each entry, instead of a whole page of complete text? I've just moved from moveable type and I love the WP interface. Very clean and efficient! The nice thing about MT was it didn't display everything at the one time

  2. stravaiger
    Member
    Posted 10 years ago #

    Thanks. Just looked at the template for index.php and changed it to get what I want:
    Where it displays the story content, put in an if check. On the front page the query string variable p isn't defined. So you can use this to stop it displaying the content for each story.
    When you click on the link of the story title, p is defined.
    I've modified index.php to only display the title and excerpt:
    change:
    <div class="storycontent">
    <?php the_content(); ?>
    </div>
    to:
    <div class="storycontent">
    <?php if ($_GET[p] != "") the_content(); else the_excerpt(); ?>
    </div>
    if the excerpt is empty, it displays the content for some reason. Probably something to do with the_excerpt()

  3. ellrond
    Member
    Posted 10 years ago #

    Isn't that because you've put the IF statement? If the excerpt is empty, it says to show the whole comment.

  4. TechGnome
    Moderator
    Posted 10 years ago #

    By default WP will return the content if there is no excerpt. Has nothing to do with the if statement and has everything to do with the way the_excerpt() works.
    TG

  5. Ruby Sinreich
    Member
    Posted 10 years ago #

    Wow, this works effortlessly. Thank you for saving me from reformatting hundreds of posts from my old MT blog!

  6. Anonymous
    Unregistered
    Posted 10 years ago #

    There is a problem with this hack. When you use this hack, the pictures you posted will not show up. Can anybody help me solve this problem? Thanks!

  7. Anonymous
    Unregistered
    Posted 10 years ago #

    That's cool, but how about a version that works with mod-rewrite rules turned on. ie; no query string...

  8. guard952
    Member
    Posted 10 years ago #

    Here's an implementation I'm currently running
    <div class="storycontent">
    <?php if (strlen(single_post_title("", false))>0){the_content();}else{the_excerpt();} ?>
    </div>

    If there is not a single post title and there is an excerpt, then it'll just print the excerpt. In all other cases it will print the entire post.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags