I am trying to set an add_action
function in my currently active WordPress theme functions.php
file, for a defined do_action
function within an activated WordPress plugin.
The add_action
function in my currently active WordPress theme functions.php
file doesn’t work.
However, it works if I copy the add_action
function from my currently active WordPress theme functions.php
file into the activated WordPress plugin file right before the do_action
function.
Is there a way to do this?
Shot in the dark here, but…
It is entirely possible the plugin with the
do_action
definition is hooked before the theme is processed.Find out where the
do_action
is defined, and find out when it is being hooked.You might need to hook to the function that the
do_action
definition is hooked too, and THEN hook to that action definition.Example:
Open the plugin file that has the
do_action
definition you are trying to hook to with your custom function.Look to see if the
do_action
definition resides within a plugin function.If so, look through the plugin to find an
add_action()
reference of that particular function name containing thedo_action
definition.Note down what that hook is.
Now, you know when WordPress calls that plugin’s function containing the
do_action
definition.So now in your theme
functions.php
file, you might have something similar to the following code: