I'm trying to override a parent theme filter in a child theme; I must have the syntax wrong as the override is being completely ignored. Here's what's in my child theme's functions.php:

//* remove and replace parent filter
function child_remove_parent_function() {

//* my custom function
function child_function($link){
    //* function code here
    return $link;

The child theme is definitely in use - I initially tried copying & customizing the function and got the 'cannot redeclare function' error. Just not sure why I can't replace the filter.

I even tried leaving just

function child_remove_parent_function() {

to see if the outputted link would break but that didn't do anything either. What am I missing?

2 Answers 2


I do not see you actually calling child_remove_parent_function() in your code.

Another issue to be aware of is timing. It is counter–intuitive, but functions.php files are loaded in order of child first, parent second.

Overall you need to ensure two things:

  1. code works at all
  2. it is called at the appropriate moment, after parent theme is done with its set up
  • OK - would I just need to add add_action( 'after_setup_theme', ' child_remove_parent_function' );? Oct 5, 2015 at 13:23
  • I'm totally confused now. I know I can do this by editing the parent theme but that would be overridden by an update. Calling child_remove_parent_function() in my child theme's functions breaks the site. Oct 5, 2015 at 13:37
  • Tried function child_remove_parent_function() { remove_filter('filter_name','parent_function'); } add_action( 'after_setup_theme', 'child_remove_parent_function' ); but still no dice. Can I get some help from someone? Oct 12, 2015 at 11:39

I faced the same problem, and found the solution: to add a priority using the third parameter of the add_action function.

This is the definition of the function:

add_action( string $hook_name, callable $callback, int $priority = 10, int $accepted_args = 1 ): true

So, for example, instead of just: add_filter('filter_name','child_function'); ... this: add_filter('filter_name','child_function',20);

I hope it helps!

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.