WordPress.org

Ready to get started?Download WordPress

Forums

How to Exerpt Blog Posts in PHP? (6 posts)

  1. carlocab123
    Member
    Posted 6 years ago #

    I want to excerpt all my posts in the homepage and /page to a number of words.

    I would also like to add a "Click here" to continue text below it. Something like this:

    Lorem ipsum dolor sit amet I don't knwo whats next...

    Click Here to Continue >

    How do I code that in php? I saw the hemingway theme did it, but I can't understand because all the code is in the funtions.php

    I would really appreciate your help guys.
    Thanks

  2. shadow
    Member
    Posted 6 years ago #

    One method:

    <?php the_excerpt(); ?><a href="<?php the_permalink(); ?>">Click here to continue</a>

  3. carlocab123
    Member
    Posted 6 years ago #

    Hi Shadow,

    Thank you for that but it's not the one I'm looking for.

    I need a code that will automatically excerpt all my posts in the homepage and /page like what the theme hemingway did.

    Thanks.

  4. shadow
    Member
    Posted 6 years ago #

    Well, if you put that code in the index.php and page.php files in your theme to replace <?php the_content(); ?>, it will be automatic.

    Or do you mean you want it to automatically happen without changing anything?

  5. carlocab123
    Member
    Posted 6 years ago #

    I used the code you gave me above:

    <?php the_excerpt(); ?><a href="<?php the_permalink(); ?>">Click here to continue</a>

    Although it excerpted the posts automatically, is there a way to choose how many words will it show before the cut?

    I also want to remove the '[…]' and turn it into '...'

    Thanks

  6. shadow
    Member
    Posted 6 years ago #

    You may want to try Kafkaesqui's excellent plugin as an alternative.

    http://guff.szub.net/2005/02/26/the_excerpt-reloaded/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags