• Resolved gulliver

    (@gulliver)


    In a child theme, I want to change the custom ‘read more’ link text set in functions.php

    // Custom more-link text
    add_filter( 'the_content_more_link', 'hemingway_custom_more_link', 10, 2 );
    
    function hemingway_custom_more_link( $more_link, $more_link_text ) {
    	return str_replace( $more_link_text, __('Continue reading', 'hemingway'), $more_link );
    }

    I’ve read what i can understand about replacing functions, but can’t get the syntax right.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Not clear on exactly what you want to do. Do you just want to change the function you showed, or remove that function and create a new one? What do you want the link to say?

    Thread Starter gulliver

    (@gulliver)

    Thanks.

    I just want to be able to change the ‘Continue reading’ text.

    If the function you showed is in the parent’s functions.php, then you need to remove the filter and add your own function. Try this:

    remove_filter( 'the_content_more_link', 'hemingway_custom_more_link', 10, 2 );
    
    add_filter( 'the_content_more_link', 'my_custom_more_link', 10, 2 );
    
    function my_custom_more_link( $more_link, $more_link_text ) {
    	return str_replace( $more_link_text, __('Read More', 'hemingway'), $more_link );
    }
    Thread Starter gulliver

    (@gulliver)

    Excellent. Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Remove filter from child theme’ is closed to new replies.