WordPress.org

Ready to get started?Download WordPress

Forums

How to add a "Read more..." tag to the_excerpt? (5 posts)

  1. kulani
    Member
    Posted 4 years ago #

    I am handcrafting excerpts for all my posts and want to add a "Read more..." tag right after the excerpt on the index page.

    I can't find a solution on how to do this. Tried the "the-excerpt-reloaded.php" plug-in but that doesn't help me either. Do I need to change the functions.php? If yes, how would I go about that? Thanks for your help!

  2. Shane G
    Member
    Posted 4 years ago #

    Hi,

    You need to edit the index.php file of your theme and replace the_content with the_excerpt

    Thanks,

    Shane G.

  3. kulani
    Member
    Posted 4 years ago #

    I've done that already - but how do I get the "Read more..." added to it without a line break?

  4. Christiann
    Member
    Posted 4 years ago #

    I did this in the functions.php file in my theme to remove the markup and the [...]

    <?php
    function change_excerpt($content) {
    	$content = str_replace('[...]','...',$content); // remove [...], replace with ...
    	$content = strip_tags($content); // remove HTML
    	return $content;
    }
    add_filter('the_excerpt','change_excerpt');
    ?>

    Then I put this in place of the_content('Read more'); in my theme:

    <p><?php the_excerpt(); ?>
    <a href="<?php the_permalink() ?>">Read more</a></p>

    Works for me!

  5. kulani
    Member
    Posted 4 years ago #

    Perfect! Many thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic