How To Remove The Callback From The add_action Hook?

WordPress callback function attached to the add_action() hook can be removed using remove_action(). Refer WordPress Codex for details.

If you’re modifying the theme, use the snippet in functions.php and in case you’re writing a plugin, you can use this snippet in your plugin file.

Let us look at a real world example. I wanted to remove the Breadcrumb added by WooCommerce in one of the projects in my day job. WooCommerce attaches the woocommerce_breadcrumb() callback to the woocommerce_before_main_content hook.

WooCommerce hook

And to remove the callback, all I’ve to do is the following. Remember the $function_to_remove and the $priority must match in order the remove the callback function.

Removing the callback using functions.php

Leave a Reply

Your email address will not be published. Required fields are marked *