• Hi,

    I just want to remove the “Continue Reading” link from my index page of posts. I’ve found this in the main twentyten functions.php file.

    function twentyten_continue_reading_link() {
    	return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
    }

    So my theme is a child theme, and in that directory I want to put

    function twentyten_continue_reading_link() {
    	return ' <a href="'. get_permalink() . '">' . __( '', 'twentyten' ) . '</a>';
    }

    but it breaks saying that the function is already defined. How do I add this to my child functions.php file without breaking it. Is there a way to undeclare a function?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can’t undeclare a function or override it, but Twenty Ten provides a way to get around this particular function. It is called from twentyten_auto_excerpt_more() which is added as a filter to excerpt_more.

    The instructions are in the functions.php code:

    /**
     * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
     *
     * To override this in a child theme, remove the filter and add your own
     * function tied to the excerpt_more filter hook.
     *
     * @since Twenty Ten 1.0
     * @return string An ellipsis
     */
    function twentyten_auto_excerpt_more( $more ) {
    	return ' &hellip;' . twentyten_continue_reading_link();
    }
    add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
    Thread Starter Zaphod

    (@zaphod)

    Still a bit lost. Do I add

    remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );

    to my child functions.php and then add

    function twentyten_continue_reading_link() {
    	return ' <a href="'. get_permalink() . '">' . __( '', 'twentyten' ) . '</a>';
    }

    Not quite. You want to remove the built-in filter and add one of your own.

    Add the remove_filter() and then add a function of your own, with your own unique name, and add it as a filter to ‘excerpt_more’.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to amend a function in the functions.php file but copy to a child theme….’ is closed to new replies.