I created my own child theme. Everything works great except I can’t seem to unregister a hoook.
$this is class TC_footer_main
and the following code is in the __construct
add_action ( '__colophon' , array( $this , 'tc_colophon_center_block' ), 20 );
I tried several remove actions with no success. I am just trying to change/remove the footer:
remove_action( '__colophon' , 'tc_colophon_center_block' , 55);
or
remove_action( '__colophon' , array('TC_footer_main','tc_colophon_center_block') , 55);
I’ve also tried
remove_action( '__colophon' , TC_footer_main::$instance->tc_colophon_center_block() , 55);
But that threw an error as TC_footer_main
was not loaded by the time my functions.php
file ran.
I think you’re making it way more complex, to modify the output of the
tc_colophon_center_block()
method, than it has to be.Just use the
tc_credits_display
filter:to modify that block to your needs.
To totally remove the output (if that’s allowed), simply use:
You have further access to filters like:
tc_copyright_link
tc_credit_link
tc_wp_powered
to choose from.
That’s it!
For your purpose add the following code in function.php. It will get call on after_setup_theme hook.
You can also try for overriding the parent class from child class as described here: https://thethemefoundry.com/tutorials/advanced-customization-replacing-theme-functions/
you werent too far away…one problem you may have is you are trying to remove the hook before it has been added by your parent theme..the class could be initialized at a later stage…
im not too sure when your hook runs, but hopefully its after init
you can obviously now just add a action for your new function.
There is a offchance that a anonymous function has been added, often the significance of
&$this
is overlooked when trying to remove a hooked function. This is a pain because wp will assign a random string as the key name & the function name for the function, its different every time so it cant be guessed. But we can search for the function name within the key so something like this will work