I’m working with a plugin that declares a function using this format:

if (!function_exists('ABdevDND_get_current_post_type')){
    function ABdevDND_get_current_post_type() {
       ...
    }
}

I’m trying to declare it in my theme’s functions.php file, by just using:

function ABdevDND_get_current_post_type() {
    ...
}

But my timing is wrong, and I’m getting Fatal error: Cannot redeclare ABdevDND_get_current_post_type().

How and where can I declare this function so it’s declared before the plugin?

2 Answers
2

You cannot do that in a theme, because themes are loaded after plugins.

Use a custom plugin, maybe a mu-plugin to be sure, because they are loaded earlier than normal plugins.

Leave a Reply

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