How to override function in functions.php of parent theme?

I have created child of theme twentyten. I tried to override function written below

    /**
 * Returns a "Continue Reading" link for excerpts
 *
 * @since Twenty Ten 1.0
 * @return string "Continue Reading" link
 */
function twentyten_continue_reading_link() {
    return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
}

/**
 * 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' );

It says to override this in a child theme, remove the filter and add your own function tied to the excerpt_more filter hook. I don’t want to make any change in the parent theme folder so created functions.php in child theme folder. I write my function in child file functions.php as below

f

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


function twentyten_auto_excerpt_more_( $more ) {
    return ' &hellip;' . twentyten_continue_reading_link_();
}
add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more_' );

But I have to comment filter written in the parent to make the new one working. Is it possible to do without modifying in parent file functions.php.

Any help will be appreciated. Thanks in advance

1 Answer
1

Hi using Function Reference/remove action and usingFunction Reference/remove filter.using these two functions only we can overriding the functions.

Leave a Comment