How to Solve “Fatal Error: Call to Undefined Function is_plugin_active()” Problem on WordPress

Written by
(Last Modified: 5 March 2016)

Wordpress logo
Do you ever get this error message?

Fatal error: Call to undefined function is_plugin_active() in some-locationsome-file.php on line xxx

Let's find out what is this error and how to solve it.

The function is_plugin_active is useful if you want to do something that is depended on a plugin. For example: If you want to display text "Hello" when a specific plugin is activated, you use this code:

if (is_plugin_active('specific-plugin-directory/specific-plugin-name.php')){
    echo 'Hello';
}

The problem occurs because the function that control is_plugin_active is not loaded before your code which is likely to happen if you place it in a theme / template / front end.

The workaround for this it to add this line:

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

So your code will be like this:

include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if (is_plugin_active('specific-plugin-directory/specific-plugin-name.php')){
    echo 'Hello';
}

Hope this helps you. 🙂

Written by Dhyayi Warapsari
22 August 2014 (Last Modified: 5 March 2016)
Category: , , , ,
Tag: ,

5 Comments

Add new comment

Leave a Reply

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