Wordpress global variables

Source: Internet
Author: User
Tags wordpress version

We often need to call global variables of the wordpress system during theme development or plug-in development using wordpress, such as the post object $ post, wordpress version $ wp_version, database Object $ wp_query, etc. If we understand these objects, It is very helpful for our wordpress team to perform secondary development.

If you want to access a global variable in your code, the first thing to do is to declare this variable with global: global $ variable;

  Internal cycle variable

In a loop, these global variables are set to store information about the page currently being processed.

$ Post the entire post object.

$ Authordata (object) returns an object containing information about the author, which can be displayed on the document details page.

$ Currentday

$ Currentmonth the month when the article is published

The number of pages in the $ pages (int) post, used for paging.

$ Multipage (boolean) returns true if post has multiple pages. Related to $ page and $ pages.

$ More (boolean) returns true. If there are multiple pages in the article, it is related to $ page and $ pages.

$ Numpages (int) returns the total number of pages in an article, which is related to $ page and $ pages.

  Browser detection of global variables

If you need to check the current browser and platform, you need to use the following global variables:

$ Is_iphone (boolean) iPhone Safari

$ Is_chrome (boolean) Google Chrome

$ Is_safari (boolean) Safari

$ Is_NS4 (boolean) Netscape 4

$ Is_opera (boolean) Opera

$ Is_macIE (boolean) Mac Internet Explorer

$ Is_winIE (boolean) Windows Internet Explorer

$ Is_gecko (boolean) FireFox

$ Is_lynx (boolean) Lunix

$ Is_IE (boolean) Internet Explorer

 Web Server Detection global variables

The following is the information about the current server. It seems that there is no Nginx.

$ Is_apache (boolean) Apache HTTP Server

$ Is_IIS (boolean) Microsoft Internet Information Services (IIS)

$ Is_iis7 (boolean) Microsoft Internet Information Services (IIS) v7.x

  Version variable

Used to check the system version information:

$ Wp_version (string) installed WordPress version

$ Wp_db_version (int) database version

$ Tinymce_version (string) installed TinyMCE version

$ Manifest_version (string) cache manifest version

$ Required_php_version (string) PHP version required by WordPress

$ Required_mysql_version (string) MySQL version required by WordPress

Others

Including global variables of some database objects:

$ Global instance of wp_query (object) WP_Query class.

$ Wp_rewrite (object) Global instance of the WP_Rewrite class.

$ Global instance of wp (object) WP class.

$ Global instance of wpdb (object) wpdb class.

$ Wp_locale (object)

$ Pagenow (string) used in wp-admin

$ Allowedposttags (array)

$ Allowedtags (array)

Reprinted Please note: http://www.54ux.com/a-2199.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.