MikeSchinkel (talk | contribs) m ($wp_meta_boxes is an array, not an object.) |
|||
(9 intermediate revisions by 5 users not shown) | |||
Line 14: | Line 14: | ||
'''Accessing other globals besides the ones listed below is not recommended.''' |
'''Accessing other globals besides the ones listed below is not recommended.''' |
||
+ | |||
+ | Developers are advised to consider this a Reserved Name List, and not to create local variables with the same names in Plugins or Themes. Under some circumstances, the global variable value will be replaced by the local variable value, causing errors in the WordPress Core that are difficult to diagnose. |
||
===Inside the Loop variables=== |
===Inside the Loop variables=== |
||
While inside the loop, these globals are set, containing information about the current post being processed. |
While inside the loop, these globals are set, containing information about the current post being processed. |
||
− | * <tt>$post</tt> The |
+ | * <tt>$post</tt> (<tt>WP_Post</tt>) The post object for the current post. Object described in [[Class_Reference/WP_Post]]. |
+ | * <tt>$posts</tt> (Used by some core functions, not to be mistaken for $query->$posts). |
||
− | * <tt>$authordata</tt> (<tt> |
+ | * <tt>$authordata</tt> (<tt>WP_User</tt>) The author object for the current post. Object described in [[Class_Reference/WP_User]]. |
− | * <tt>$currentday</tt> Day of the post. |
||
− | * <tt>$ |
+ | * <tt>$currentday</tt> (<tt>string</tt>) Day that the current post was published. |
− | * <tt>$ |
+ | * <tt>$currentmonth</tt> (<tt>string</tt>) Month that the curent post was published. |
− | * <tt>$ |
+ | * <tt>$page</tt> (<tt>int</tt>) The page of the current post being viewed. Specified by the query var page. |
− | * <tt>$ |
+ | * <tt>$pages</tt> (<tt>array</tt>)The content of the pages of the current post. Each page elements contains part of the content separated by the <nowiki><!--nextpage--></nowiki> tag. |
− | * <tt>$ |
+ | * <tt>$multipage</tt> (<tt>boolean</tt>) Flag to know if the current post has multiple pages or not. Returns true if the post has multiple pages, related to $pages. |
− | * <tt>$ |
+ | * <tt>$more</tt> (<tt>boolean</tt>) Flag to know if WordPress should enforce the <nowiki><!--more--></nowiki> tag for the current post. WordPress will not enforce the more tag if true. |
+ | * <tt>$numpages</tt> (<tt>int</tt>) Returns the number of pages in the post, related to $pages. |
||
===Browser Detection Booleans=== |
===Browser Detection Booleans=== |
||
Line 41: | Line 44: | ||
* <tt>$is_lynx</tt> (<tt>boolean</tt>) |
* <tt>$is_lynx</tt> (<tt>boolean</tt>) |
||
* <tt>$is_IE</tt> (<tt>boolean</tt>) Internet Explorer |
* <tt>$is_IE</tt> (<tt>boolean</tt>) Internet Explorer |
||
+ | * <tt>$is_edge</tt> (<tt>boolean</tt>) Microsoft Edge |
||
===Web Server Detection Booleans=== |
===Web Server Detection Booleans=== |
||
Line 48: | Line 52: | ||
* <tt>$is_IIS</tt> (<tt>boolean</tt>) Microsoft Internet Information Services (IIS) |
* <tt>$is_IIS</tt> (<tt>boolean</tt>) Microsoft Internet Information Services (IIS) |
||
* <tt>$is_iis7</tt> (<tt>boolean</tt>) Microsoft Internet Information Services (IIS) v7.x |
* <tt>$is_iis7</tt> (<tt>boolean</tt>) Microsoft Internet Information Services (IIS) v7.x |
||
+ | * <tt>$is_nginx</tt> (<tt>boolean</tt>) Nginx web server |
||
===Version Variables=== |
===Version Variables=== |
||
Line 69: | Line 74: | ||
* <tt>$wp_roles</tt> (<tt>[[Class_Reference/WP_Roles |WP_Roles]]</tt>) |
* <tt>$wp_roles</tt> (<tt>[[Class_Reference/WP_Roles |WP_Roles]]</tt>) |
||
* <tt>$wp_meta_boxes</tt> (<tt>array</tt>) Object containing all registered metaboxes, including their id's, args, callback functions and title for all post types including custom. |
* <tt>$wp_meta_boxes</tt> (<tt>array</tt>) Object containing all registered metaboxes, including their id's, args, callback functions and title for all post types including custom. |
||
+ | * <tt>$wp_registered_sidebars</tt> (<tt>array</tt>) |
||
+ | * <tt>$wp_registered_widgets</tt> (<tt>array</tt>) |
||
+ | * <tt>$wp_registered_widget_controls</tt> (<tt>array</tt>) |
||
+ | * <tt>$wp_registered_widget_updates</tt> (<tt>array</tt>) |
||
===Admin Globals=== |
===Admin Globals=== |
Languages: English • Italiano • 日本語 中文(简体) • (Add your language)
WordPress-specific global variables are used throughout WordPress code for various reasons. Almost all data that WordPress generates can be found in a global variable.
Note that it's best to use the appropriate API functions when available, instead of modifying globals directly.
To access a global variable in your code, you first need to globalize the variable with global $variable;
Accessing other globals besides the ones listed below is not recommended.
Developers are advised to consider this a Reserved Name List, and not to create local variables with the same names in Plugins or Themes. Under some circumstances, the global variable value will be replaced by the local variable value, causing errors in the WordPress Core that are difficult to diagnose.
While inside the loop, these globals are set, containing information about the current post being processed.
These globals store data about which browser the user is on.
These globals store data about which web server WordPress is running on.