4

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

4

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

1
  • Thank you Ramkumar ... I used this and it worked add_action( 'after_setup_theme', 'my_child_theme_setup' ); function my_child_theme_setup() { // We are providing our own filter for excerpt_length (or using the unfiltered value) remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' ); }
    – user478
    Commented Jul 1, 2011 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.