I created a plugin to override a theme’s function. As I learn that function in plugin loads first but I got an error

Fatal error: Cannot redeclare wooc_extra_register_fields() (previously
declared in ****/themes/****/functions.php:247) in
***/plugins/custom-plugin/custom-plugin.php on line 89

Not sure what I am doing wrong.
Also put theme’s functions need to be override in if !function exist.
So what is the right way to override a theme function wrap in !function exist using a plugin??

2 Answers
2

In wp-settings.php, WordPress first checks for any must-use plugins (plugins in the optional mu-plugins folder) and loads those.

Then, if you’re running a multisite installation, it checks for plugins that are network-activated and loads those.

Leave a Reply

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