A fresh mix of code snippets and tutorials

WordPress check if plugin is active

Developing WordPress plugins, it’s super useful to know if another specific plugin is active. Fortunately WordPress makes it easy to do, read on to learn how..

To check if a plugin is active, we can use is_plugin_active(). There are two ways to use this function, depending on whether you’re in the Admin Area or on the front-end (i.e., via theme template).

Check in Admin Area

If you’re running in the WP Admin Area, you can use the function as-is, for example:

if (is_plugin_active('plugin-directory/plugin-file.php')) { 
	// plugin is active

Note that the parameter accepted by is_plugin_active() is required and must include both the plugin subdirectory and the name of the main plugin file.

Check on front-end

As explained in the WP Codex:

is_plugin_active() is defined in /wp-admin/includes/plugin.php, so this is only available from within the admin pages, and any references to this function must be hooked to admin_init or a later action. If you want to use this function from within a template, you will need to manually require plugin.php.

So with that in mind, here is an example of using the function to check if a plugin is active when on the frontend:

include_once(ABSPATH .'wp-admin/includes/plugin.php');

if (is_plugin_active('plugin-directory/plugin-file.php')) { 
	// plugin is active

The function returns either true or false depending on whether or not the specified plugin is active.


Learn more

Digging Into WordPressWordPress Themes In DepthWizard’s SQL Recipes for WordPress