I need to override the function get_cancel_comment_reply_link or cancel_comment_reply_link that are defined in


These functions are not listed in pluggable.php.

How can I override them from my theme's functions.php?

I tried

remove_filter('get_cancel_comment_reply_link', 'cancel_comment_reply_link');
add_filter('get_cancel_comment_reply_link', function($text='') { return ''; }, 1, 1);

without success.


If you look at the end of the function get_cancel_comment_reply_link( $text = '' ) in the file wp-includes/comment-template.php, you see the filter cancel_comment_reply_link.

return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text );

It may work.

  • Thank you. How to disable this then, without modifying a file in wp-includes?
    – Basj
    Dec 2 '21 at 15:04
  • Try, in your functions.php for a theme or a child theme, or in a plugin : add_filter( 'cancel_comment_reply_link', '__return_false' );
    – xavier bs
    Dec 2 '21 at 15:09
  • I did add_filter('cancel_comment_reply_link', function($link) { return ''; }, 10); in the meantime and I confirm it works! Thanks! By the way, why does adding a filter work here? Does adding a filter override other functions? I thought that adding would execute all functions and not override the first one (defined in wp-includes). Do you have information about this?
    – Basj
    Dec 2 '21 at 15:12
  • Perhaps, it's the only time the filter is executed with the priority 10. You don't have to put here the priority, because 10 is the default. If the filter is used more than once, you may have to change the priority to be executed after. You need to define the same priority just to remove a filter with the function remove_filter(). But if the filter is defined inside a dynamic class, it's another more difficult story.
    – xavier bs
    Dec 2 '21 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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