Archived topic
Problem with remove_action
3 replies · Started by Marcel Kuhla on September 12, 2022
Hey Guys,
Based on your theme and premium plugin, I'm working on a refresh of our news site. I would have added the secondary menu via add_action to the inside of the primary menu, but I can't get it removed afterward.
I tried
remove_action('generate_after_navigation', 'generate_add_secondary_navigation_after_header', 5);
but for some reason it does nothing. I also tried generate_after_header because I thought that maybe both navigations hook the same, but it also doesn't work.
What am I doing wrong?
Regards,
Marcel
Hi Marcel,
Try changing the 5 to 7, and changing generate_after_navigation to generate_after_header.
Hey Ying,
thank you for the answer, it worked :) But could you please explain to me why 5 doesn't work?
I was going through the files and thought that everything gets priority 10 so 5 and 7 are both lower.
The WordPress docs aren't really helpful in regards to that, but maybe you can give me an explanation that I can remember for the future 😅
Regards,
Marcel
But could you please explain to me why 5 doesn’t work?
Because when we add the secondary navigation, we used 7 :)
You can find the original code below:
https://github.com/tomusborne/gp-premium/blob/2189fbebd60573971b0739a98917b49ab26f550c/secondary-nav/functions/functions.php#L478