WordPress is_plugin_active() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Conditional tag

Definition

In WordPress, is_plugin_active() returns true when a given plugin is active on the current site. Otherwise it returns false.

The plugin is named by its path inside the plugins folder, such as akismet/akismet.php. Themes and plugins use this check to turn on extra features only when another plugin is ready.

Syntax

Use it as the test of an if statement.

WordPress
if ( is_plugin_active( 'akismet/akismet.php' ) ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_plugin_active( 'akismet/akismet.php' )True if Akismet is active.
is_plugin_active( 'woocommerce/woocommerce.php' )True if WooCommerce is active.
! is_plugin_active( $plugin )True if the plugin is not active.

On the front end, load the function first with require_once ABSPATH . 'wp-admin/includes/plugin.php';.

Full declaration
WordPress
is_plugin_active( string $plugin ): bool

Parameters

ParameterDescription
$pluginRequired. The path of the main plugin file, relative to the plugins folder, for example akismet/akismet.php.

Return Value

Return ValueDescription
booltrue if the plugin is active, otherwise false.

WordPress Examples

Three short theme examples. Each one shows what prints on the true path and the false path.

Example 1 — Include plugin.php first

Make the function available in a theme file.

WordPress
<?php
if ( ! function_exists( 'is_plugin_active' ) ) {
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

if ( is_plugin_active( 'akismet/akismet.php' ) ) {
  echo 'Akismet is active.';
} else {
  echo 'Akismet is not active.';
}

How It Works

  1. function_exists() checks if the function is already loaded.
  2. require_once loads plugin.php when it is missing.
  3. Then the if and else print the result.

Example 2 — Turn on a theme feature

Show a shop link only when WooCommerce is active.

WordPress
<?php
include_once ABSPATH . 'wp-admin/includes/plugin.php';

if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
  echo '<a href="/shop/">Shop</a>';
} ?>

How It Works

  1. The plugin path is folder/main-file.php.
  2. The link is printed only when the plugin is active.
  3. Your theme will not break if the plugin is turned off.

Example 3 — Safer check with class_exists()

Check for the plugin code itself.

WordPress
<?php if ( class_exists( 'WooCommerce' ) ) {
  echo 'WooCommerce code is available.';
} ?>

How It Works

  1. class_exists() needs no extra file.
  2. It checks that the plugin is loaded, not just active.
  3. Many developers prefer this on the front end.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
The function lives in wp-admin/includes/plugin.php. Include that file before you call it on the front end.
It is the folder and main file, such as akismet/akismet.php. You can see it in the plugin file header or in the active_plugins option.
Use is_plugin_active_for_network() for plugins that are activated across a Multisite network.

Next: is_post_type_archive()

Check if the current page is a custom post type archive.

is_post_type_archive() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful