As the name implies, the function is mainly used to display the blog information; and according to the different parameters, can be used to display the different parts of the blog information. Commonly used are the following:
bloginfo (‘name’) shows the blog title, such as “site”; default (do not write parameters) output the item;
bloginfo (‘description’) shows the blog description part, such as “the road is far from its repair Xi, I will be up and down and quest”;
bloginfo (‘url’) output blog URL address, such as http://www.cmsjzy.cn;
bloginfo (‘rss2_url’) shows the blog’s RSS2.0 feed address, such as http://www.cmsjzy.cn/feed;
bloginfo (‘template_url’) is used to get the template address of the WordPress blog;
bloginfo (‘charset’) shows how the blog is encoded, such as “UTF-8”;
A common combination of using the bloginfo () function is as follows:
“Title =” “>
This form is usually used to add the bottom of the blog information, such as Copyright @ site, often used in the theme template.
Note that the bloginfo () function can only output these parameters. If you want to use these values in a PHP statement, you need to use the get_bloginfo () function, which uses the same parameters as bloginfo () to get the same result.
The function is used to display the title of the page, as in the article page, the article title is displayed; on the category page, the category name is displayed;
wp_title () function can be followed by three parameters, namely wp_title (‘separator’, echo, seplocation), where separator is the division between the title and the rest of the symbol, the default is >>; echo is a bool variable, False to return the title as a PHP parameter; seplocation defines the location of the delimiter, and right defines the delimiter after the title, whichever is any value, and indicates that the delimiter is placed before the title.
This function is used to get the blog’s article archive, and by setting the parameters of the function, you can get it in various ways, such as month, year, and so on.
The wp_get_archives () function can also be followed by a variety of arguments, except that all parameters need to be treated with a & link and placed in a single quotation mark (‘) as a string, as in wp_get_archives (‘ type = monthly & format = html & show_post_count = 1 & limit = 10 ‘).
The above parameters are described as follows:
type = monthly means to display article archives on a monthly basis, you can use yearly, daily, weekly, etc. instead of monthly that year, day, and week show article archive;
# format = html means to use the usual HTML formatted article list;
show_post_count = 1 means that the number of articles belonging to the category (year, month, etc.) is displayed after the article archive, which is a bool value;
limit = 10 means that the maximum number of articles archived is 10, the number of times exceeded, then the part is not displayed;
Although the parameters slightly more, it is slightly complicated, but in fact only pay attention to type, show_post_count and limit three parameters can be.
Similar to the wp_get_archives () function, the wp_list_categories () function is used to get the classification information for a blog post and can be displayed by setting the appropriate function parameters. The parameters of the function and wp_get_archives () function similar to the need to use & link, put in single quotation marks (‘) to pass the string. Form like wp_get_archives (‘orderby = name & order = ASC & show_count = 1 & use_desc_for_title = 1 & feed = subscribe & exclude = 2,5 & number = 10’).
In the example above, the meaning of the function parameters is as follows:
orderby = name that according to the name of the alphabetical order of classification information, you can change the name ID;
order = ASC indicates that the classification information is displayed in ascending order of the alphabetical name of the category name, and ASC is changed to DESC in descending order;
show_count = 1 The number of articles belonging to the category is displayed after each category name;
use_desc_for_title = 1 Use the description of the category to add a title attribute for each category name hyperlink;
feed = Subscription: Add a hyperlink named “Subscription” next to each category to provide the RSS feed for that category;
exlude = 2,5: in the display of the classification to remove the ID 2 and 5 of the classification; can also use include = 2,5 that only show the ID of 2 and 5 classification;
number = 10: Indicates that only the first 10 categories are displayed.
The get_the_category () function is used to return an array of properties of the category to which the current article belongs, which includes the following:
cat_ID: ID of the current category (can also be written as ‘term_id’);
cat_name: the name of the current category (also written as ‘name’);
category_description: description of the current classification (can also be written as ‘description’);
category_count: The number of articles that belong to the current category (also written as ‘count’).
The specific use of the method, we through the following several sentences to illustrate:
A statement such as get_the_category () -> cat_ID, returns the ID number of the category to which the current article belongs;
Such as get_the_category () -> description of the statement, return to the current article belongs to the description of classification;
This function returns the name of the category to which the current article belongs, and is a hyperlink to the article category.
The default no parameter form the_category () directly displays the category name as a hyperlink, as:
You can format the output, such as the_category (‘-‘), if the current article belongs to more than two categories, you can display such a form: It is displayed in such a form: fine promotion.
This function takes the classified ID as input and gets the description of the classification. And often echo, get_the_category () with the use of the current classification description output:
echo category_description (get_the_category () -> cat_ID);
Get_the_category () get an array of the current classification information; cat_ID is the ID of the class in the array; enter the ID into the category_description () function to get the description of the class; then use echo to output it The
But by the site test, the use of the following statement can achieve the same function and the above statement:
echo category_description ();
This may be because the function outputs the result of the current classification description in the case of default no parameter input.
is_home () to determine whether the currently displayed blog page is the blog home page and return a Bool value. Returns TRUE if it is on the home page; otherwise returns FALSE.
This function is often used to control the way the blog sidebar is displayed, often using the following code snippet:
is_archive () to determine whether the currently displayed content is a blog archive page, such as a date archive, or by archive, and so on; it returns a Bool value just like the is_home () function.
The is_page () function determines whether the currently displayed content is a separate page of the blog, such as “WordPress”, “About this site”; it also returns a Bool value.
We can in the template through the function to determine whether the current is a separate page to determine whether the current display of the article shows the release time and so on.
This function is used to determine whether the current article is tabulated because of too much content. Note that the function does not return TRUE if you have manually added a label to force paging when writing an article.
The is_page_template () function takes a parameter, usually in the following way:
To determine whether the current display of the independent page (page) using the parameters shown in the template guestbook.php; if not with the parameters, the function returns the current independent page whether the use of the template.
is_single () to determine whether the currently displayed page content is a separate article. One can be followed by three parameters, one is the article ID; one is the article title (title); one is the article name (slug, article title of a short description of the form); or can be used in combination of three parameters, To determine whether the current page content is a specific article.
A simple example is as follows, we can through the following ways to determine whether the current display is the text:
is_single (‘808’); is_single (‘use-wordpress-second’); is_single (‘808’); is_single (‘ Do not know the function (b) ‘,’ functions-must-known-using-wordpress-second ‘);
Here, the site needs to do the last one of the above description: the function followed by three parameters, there is a priority, if the first parameter meets the conditions, then return TRUE; otherwise, return FALSE; looks like the following parameters And it does not make sense.
The function is used to determine whether the currently displayed page content is a sorted page, such as site-related; where no parameters are required. The function returns a Bool value.
is_tag () to determine whether the currently displayed page is a tab page, such as WordPress; then do not need to follow the parameters. The function also returns a Bool value.
This function is used to determine whether the currently displayed content is a time-archived page, such as April 2009, or April 8, 2009, and so on.
17.is_day (), is_month (), is_year ()
These functions are used to determine whether the currently displayed content is a page by day, month, and yearly. They are similar to is_date (), but will only archive the time more specific.
This function is used to determine whether the currently displayed content is a page with the author’s name, such as the admin author page of the site.
The is_admin () function is used to determine whether the current is on the control panel page, or the admin panel page.
This function and our previous article use WordPress do not know the function (a) described in the bloginfo () function to achieve almost the same function. Mainly used to display the information of the blog; and according to the different parameters, will output different information of the blog.
Followed by the parameters, get_bloginfo () can display the blog name, shaped like “this site”;
Followed by other parameters, you can display the corresponding information, such as get_bloginfo (‘description’) to display the blog description information;
Other parameters that can be used include name, url, wpurl, and admin_email. But because it is with the bloginfo () function to achieve the same results, so in the case of bloginfo can be achieved, this site is not recommended to use get_bloginfo () function.
The query_posts () function takes the appropriate parameters to control which articles are displayed on the page.
Such as query_posts (“cat = 3,6 & cat = -5, -10”) that take the classification of the ID of 3 and 6 of the article shows no classification ID of 5 and 10 of the article show;
The meaning is as follows: query_posts (“order = ASC & showposts = 10 & offset = 1 & orderby = date & posts_per_page = 5”)
order = ASC in ascending order, DESC is in descending order;
showposts = 10 means to get 10 articles;
offset = 1 means the latest article;
orderby = date means that the article is sorted by date;
posts_per_page = 5 means 5 articles per page.
It should be noted that the function is only the contents of the article from the MySQL database query out, to display it, but also need to cooperate with other statements, such as a frequently used in the sidebar as follows:
The above code is used to display the latest five articles at the specified location on the sidebar.
query_posts () function can be followed by a variety of types of parameters, the function is very powerful, in this, we do not introduce too much. If time and energy allow, this site will be written in a later article specifically for friends to make an introduction.
The function and query_posts () function is roughly the same, are used to query from the database and get a condition in line with the article. However, the use of the get_posts () function has a fixed form, as follows:
“Id =” post – “>
First, use the get_posts () function to get the article data, and then use the form like foreach ($ lastposts as $ post): setup_postdata ($ post); The loop will query the contents of the article displayed.
The get_posts () function uses the same parameters as the query_posts () function, and we will not go into detail here.
This function has the same functionality as the wp_list_categories () function in WordPress. However, in the latest version of WordPress, this function has been deprecated and its function is completely replaced by the wp_list_categories () function.
The get_calendar () function is used to display the calendar on WordPress, the calendar style is the same as using the widget, as shown in the following figure:
Which can then be followed by a BOOL parameter to control the display style of the week above the calendar. But by the site test, in the Chinese state, the use of TRUE or FALSE parameters, the calendar display is no different.
This function is used to display the blog’s links and can use various parameters to control the number, type, and style of the display.
Form, such as wp_list_bookmarks (‘title_li = & categorize = 0 & orderby = rand & include = 41,40,37,54’); form, meaning explained as follows:
title_li = & categorize = 0 is a commonly used combination, does not show WordPress background control panel set in the link title, but all the chain are displayed in accordance with the classification of the show; a separate title_li = can also be used to set The name of the category showing the chain;
orderby = rand set the chain display in a random order, of course, can also be set to other ways, such as id, url, name and so on;
include = 41,40,37,54 only show the ID of the four numbers of the four friends; Corresponding to this, also supports the use of exclude, said the number of friends do not show the number of links.
# In addition, the function often used parameters before and after, used to set each link before and after the text, the default is and
26.get_links (), wp_get_links ()
These two functions implement the same functionality as 25.wp_list_bookmarks (), but these two functions have been replaced by 25.wp_list_bookmarks () during the WordPress upgrade.
The function displays all pages within the WordPress blog as a hyperlink to the page name, often used to create a top navigation page or to decorate the sidebar.
The function is called wp_list_pages (‘title_li = & sort_column = menu_order & include = 12,25,38,57 & depth = 1 &’); The meaning of each parameter is as follows:
title_li = used to set all the display page of a total name; no parameter value behind, that does not display the name;
sort_column = menu_order used to set the order of the page display, said in accordance with the WP background settings of the page order display, the other commonly used sequence settings may also include post_title, post_date, ID, etc.;
include = 12,25,38,57 that only show the four values for the four pages; Similarly, you can use exclude to exclude the corresponding ID of the page;
depth = 1 indicates that only the parent page is displayed, and all subpages are not displayed; other values include the default 0, indicating that all pages (pages are indented); – 1 shows all pages (pages are not indented); and many more.
In addition, the properties that may be used by the function include link_before and link_after, which are used to set the characters before and after the displayed page link.
As the name suggests, the wp_tag_cloud () function is used to display the WordPress blog’s tag cloud.
A function called wp_tag_cloud (‘smallest = 8 & largest = 22 & number = 30 & orderby = count’); the meaning of each parameter is as follows:
smallest = 8 is used to set the label size of all the labels displayed in the tag cloud with a minimum count (at least article).
largest = 22 The label size for all tags that are used to set the tag cloud to the most (most used articles) is 22;
number = 30 sets the maximum number of tags displayed in the tag cloud to 30;
orderby = count Sets the sorting of tags in the tag cloud to the count (default), not the name (the default is name, the default when the widget is called).
Other commonly used parameters include include and exclude, used to set whether the tag cloud contains or remove the ID as a number of labels.
The wp_register () function is used to display the “site management” hyperlink to the administrator; or when the WP blog is open, the “registered” hyperlink is displayed to the unregistered user.
The function does not require any parameters, the only possible use of the parameters such as wp_register (‘front’, ‘after’), you can display the hyperlink text before and after the show a “front” and a “post” word. Of course, you can use this imagination to personalize your site’s management or registration links.
This function is used to display a “login” link at the specified location; of course, if you have already logged in, an “exit” link will be displayed accordingly. This function does not use any parameters later, so flexible customization is not possible.
However, if you want to customize your own WP blog login or exit the link text, you can still use the following 31 described in the function wp_logout_url () and wp_login_url ().
31.wp_logout_url (), wp_login_url ()
Using the function as above 30, although you can easily set up login for the WP blog, exit the link, but the custom is not flexible enough. So, starting with the WordPress version 2.7, there are two functions available here. They are used to get WP blog exit or login hyperlinks, and then we use the hyperlink can be prepared to write the following code to the WP blog login and exit links for flexible settings:
“Click here to exit
“Click here to log in
Of course, in order to achieve the perfect effect, but also need to judge the visitor’s login status, use an if statement, according to the login status display the corresponding menu item.
The function is usually followed by the function in the back of 29,30, the specific visual display on what is not the same, it seems WP theme for the WP plug-in left API Hook, the site suggested that friends in the function above to keep up with this A function.
This function is only available when you have installed the Chinese WordPress toolbox. Its role is used to obtain the latest log, the function prototype is as follows:
# get_recent_posts ($ no_posts = 5, $ before = ‘+’, $ after = ‘
‘, $ Show_pass_post = false, $ skip_posts = 0)
You can use the $ no_posts control to show the number of articles, $ before and $ after the meaning and the same function in the previous; As for the latter two parameters, generally do not have to set the direct value can be taken directly.
However, because the function and WordPress built-in get_posts () and query_posts () function function is repeated, so usually rarely used.
In fact, after installing the above WordPress toolbox, the most commonly used is this function, because the WordPress program itself does not have built-in access to the latest comments function. The prototype of the function is as follows:
# get_recent_comments ($ no_comments = 5, $ before = ”, $ after = ‘
‘, $ Show_pass_post = false)
Meaning Obviously, and the above function is similar to this site no longer speak.
This function is a function that is available after the WP-RecentComments plug-in is installed, similar to the function in 34 above.
The prototype of the function is as follows:
get_recentcomments (int num, int size)
The function is used to get the article’s tag on an article page or based on the ID of an article, and the result is placed in a tag array. A common use is as follows:
($ tags- $). $ “[$ keywords = $ keywords. } echo $ keywords;}
($ Post-> ID) to get the current article’s tag, and then get its name ($ tag-> name), and its combination of output.
37.single_cat_title (), single_tag_title ()
As the name suggests, these two functions are used to get the title page and tag page title, its usual use such as:
However, in addition, single_cat_title () can also be used to get the title of the current page on the tag page; but single_tag_title () is not available to get the title of the sort page.
38.get_settings (), get_option ()
The two functions and the previous use of WordPress do not know the function (c) function 20.get_bloginfo () similar to the use of the same method, you can follow the various parameters to get WordPress blog related information.
Such as the following call:
get_settings (‘name’) or get_option (‘name’)
Can be used to get the title of the current WordPress blog.
This function is the same as the previous 32.wp_meta (), which is the API Hook left by the WP theme for the WP plugin.
40.get_header (), get_footer (), get_sidebar (), and comments_template ()
These functions are used to get and include the corresponding files in the WordPress theme. such as:
get_header () is used to include the header.php under the current theme folder;
get_footer () is used to include the footer.php under the theme folder;
get_sidebar () is used to contain the sidebar.php under the theme folder;
comments_template () is used to include comments.php.
It should be noted that if the current theme folder is missing the corresponding file, the function will use the wp-content / themes / default / folder under the corresponding file instead.
In addition, the above function can not follow the parameters, only get_sidebar () exception, because a theme can use multiple sidebar. A call method such as get_sidebar (‘up’) can include the sidebar-up.php sidebar template file in the theme.
In addition to the above functions, in the subject if you want to include a specific file, you can also use the following way:
include (TEMPLATEPATH. ‘/***.php’)
The above function can be included in the current theme folder named ***. Php file; where TEMPLATEPATH is a reference to the current theme folder address (not including the end / so it needs to be added).
41.have_posts (), the_post ()
These two functions are used in a limited range and are typically used in WordPress loops to get all the articles. The fixed form of use is as follows:
The article here shows the information when the article is not found, such as 404
Another common form is to combine the first two lines in the above code (other places are the same):
This form is usually used in templates such as index.php, archive.php, or single.php. In addition to other places, we usually do not see the two functions of the figure.
42.the_title (), the_title_attribute ()
the_title () function is mainly used to get the title of the current article, then you can keep up with three parameters (all omitted, take the default value), call the form as follows:
The parameter before is used to set the character content displayed in front of the obtained title; after is used to set the content that the title is displayed later; and display is a Bool value that controls whether the obtained title is displayed.
The_title_attribute () function is similar to the_title (), which is used as follows:
the_title_attribute (‘before = front & after = post & echo = true’)
Where before = and after = are used to set the title before and after the characters; echo = true or false user to set the title string is displayed.
The call form of the form or the_title_attribute (‘before = current article & after = comments: echo = true’) will show the following result:
The current article with WordPress do not know the function of the comments:
43.single_post_title (), single_tag_title (), single_cat_title ()
The function does not follow any of the following arguments, using the following call:
Used to get and display the ID number of the current article page. However, the need to pay special attention to is that the function can only be used in the WordPress large cycle, the use of other places may also show the ID number, but the contents of the display will never change with the article.
In addition, the function is usually used in the CSS structure shown below:
You can set different title styles for different authors in your blog to distinguish.
The function and 44.the_ID () function to achieve exactly the same function, the current WordPress official did not provide the use of the function. You can refer to the above description of the_id () function in 44 above. In particular, the function is similar to the_ID (), and it can only be used correctly in WordPress loops.
46.the_time (), get_the_time ()
the_time () is used to get and display the current article published time, and the above several functions similar to this function can only be used in WordPress large cycle.
The function can be followed by the control date or time format parameters, commonly used parameters as follows:
Such as the call form of the display: June 13, 2009 (English status shown June 13, 2009);
Such as the call form shows the effect: 7: 09 pm (English state shows 7:09 pm);
Such as the call form shows the effect: 19: 09.
In fact, in addition to using the_time () function, WordPress also provides a similar function get_the_time () function. The function does not have the display function of the_time () function, the rest of the function is exactly the same. When you use the get_the_time () function, you need to use a special statement to display the acquired time.
Here, we take this opportunity to simply understand the format of WordPress in time. In WordPress, usually used to control the time format of the characters: l, F, j, S, Y, G, g, i, a, etc., its detailed meaning is as follows:
l (lowercase L) is used to display the name of each day of the week, such as Saturday, or in English show Saturday;
F is used to display the month name, such as June, or June;
j is used to show one day of the month, such as 13;
Y is used to display the year in 4 digits, y is displayed in the last two digits, such as 2009 or 09;
G, g, i, a and other four characters are usually used in combination, as in the previous example, there are two forms:
g: i a shows the time in the form of a form such as 7:09 pm or 7:09 pm;
G: i displays the time in the form of a 24-hour scale, such as 19:09.
S is usually followed by j, indicating whether or not to add the English suffix (st, nd, th, etc.) after one day of the month.