• Resolved monkeybrain

    (@monkeybrain)


    Hi everybody

    I had this custom functions in my functions.php for a while now, it replaces the […] at the end of an excerpt with a permalink. Unfortunately this stopped working with WP 3.6, does anyone have an idea why and how to fix it?

    function replace_excerpt($content) {
           return str_replace('[...]',
                   '<p class="more-link"><a href="'. get_permalink() .'">Continue Reading</a></p>',
                   $content
           );
    }
    add_filter('the_excerpt', 'replace_excerpt');

    Thanks alot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Not sure why it no longer works, but you should use the ‘excerpt_more’ filter instead of ‘the_excerpt’. Then you can simply return your content instead of needing to search for where to replace it. You end up with more robust code this way that should be more upgrade proof. See the example in this section. Also note the following paragraph about other theme filters, which may be why you have a problem, and may still be a problem using the ‘excerpt_more’ filter.

    Thread Starter monkeybrain

    (@monkeybrain)

    Thanks a lot, bcworkz!
    Using excerpt_more works! (No issues with other theme filters)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘This function stopped working with 3.6’ is closed to new replies.