WordPress Global variables list

WordPress-specific global variables are used throughout WordPress code for various reasons. Almost all data that WordPress generates can be found in a global variables list.

To access a global variable in your code, you first need to globalize the variable with global $variable

Global variables list:

$post:

The post object for the current post from wp_post table.

$authordata:

The author object for the current post from WP_User table.

$wp_query:

deals with the intricacies of a post’s (or page’s) request to a WordPress blog.

$wp_rewrite:

It is used internally when updating the rewrite rules, and also to find the URL of a specific post, Page, category archive, etc.

$wpdb:

Talks with Database, uses for connecting database to UI.

$wp_meta_boxes:

(array) Object containing all registered metaboxes, including their id’s, args, callback functions and title for all post types including custom

Admin Global variables list:

$pagenow

(string) used in wp-admin See also get_current_screen() for the WordPress Admin Screen API

$post_type

(string) used in wp-admin, used as declare new post type

$allowedposttags

(array) “allowedposttags” is used for sanitizing post_content while “allowedtags” is used for comments.

$allowedtags

(array)