How to call a plugin function from index.php

The same way you would any other:

foo();

Active plugins are loaded before the theme files

You may want to check that your plugin is activated and the function is available so things dont go pear-shaped if you forget to activate it, like:

if(function_exists('foo')){
    foo();
} else {
    echo "oh dear you haven't activated/installed 'myplugin', go do that before the 'foo' feature is available";
}

Also keep in mind foo is a very generic function name, perhaps the “omgfoo” plugin also has a foo function. So prefix/namespace your function to something unique

You will eventually want to use actions and filters, as they’re safer and better practice, you can continue to read up on that here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)