is_admin()

Determines whether the current request is for an administrative interface page.


Description Description

Does not check if the user is an administrator; use current_user_can() for checking roles and capabilities.

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.


Return Return

(bool) True if inside WordPress administration interface, false otherwise.


Top ↑

Source Source

File: wp-includes/load.php

function is_admin() {
	if ( isset( $GLOBALS['current_screen'] ) ) {
		return $GLOBALS['current_screen']->in_admin();
	} elseif ( defined( 'WP_ADMIN' ) ) {
		return WP_ADMIN;
	}

	return false;
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.5.1 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 2 content
    Contributed by hearvox

    Example:

    if ( ! is_admin() ) {
        // Runs only if this PHP code is in a file that displays outside the admin panels, like the theme template.
        echo '<div style="text-align: center">Welcome to our website.</div>';
    } else {
        // Runs only if this code is in a file that displays inside the admin panels, like a plugin file.
        echo '<div style="text-align: center">Welcome to your Admin Panels.</div>';
    }
    

You must log in before being able to contribute a note or feedback.