How To Remove The Callback From The add_action Hook?

In this post, we shall learn about removing the callback from the add_action WordPress 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

By Maria Daniel Deepak

I'm a Web and WordPress developer by day and a dog trainer by night. I'm trying to lead a habit-based life and exploring the minimalist lifestyle.

Leave a Reply

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