• keress

    (@keress)


    I’d like to use the Excerpt feature, but need it to add a “read more” link to the end. I found the following in the Codex, added it to my functions.php, but nothing happened. What am I missing?

    Make the “read more” link to the post

    Place this in a theme’s functions.php to make the “read more” link to the post

    function new_excerpt_more($post) {
    return ‘ID) . ‘”>’ . ‘Read the Rest…’ . ‘‘;
    }
    add_filter(‘excerpt_more’, ‘new_excerpt_more’);

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter keress

    (@keress)

    I’m still trying to figure out what I’m doing wrong. I did realize that the “add_filter . . .” part is the call that’s to be added to my index.php file. Still doesn’t work.

    Here’s the code I’m using:

    In index.php

    <div id="lead-article-excerpt">
    <?php the_excerpt('Read the rest of this entry &raquo;'); ?>
    <?php add_filter('excerpt_more', 'new_excerpt_more'); ?>
    </div>

    Then, in the functions.php file I added:

    function new_excerpt_more($post) {
    return '<a href="'. get_permalink($post->ID) . '">' . 'Read the Rest...' . '</a>';
    }

    Can anyone see any mistakes in the syntax, or anything else I should try?

    Thanks!

    T

    Thread Starter keress

    (@keress)

    I’ve ruled out the possibility that I’m not calling the function properly. I’m using the code from this page of the codex:

    Navigate to the wordpress.org site, then add this to the url:
    Template_Tags/the_excerpt

    and I get this error message:

    Warning: Missing argument 1 for new_excerpt_more(), called in E:\xampp\htdocs\health-healing\wp-content\themes\h&h\home.php on line 24 and defined in E:\xampp\htdocs\health-healing\wp-content\themes\h&h\functions.php on line 23

    Could it be there’s just an error in the code on the Codex? Or something missing in the instructions?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding “read more” link to excerpt’ is closed to new replies.