A detailed description of the function usage in WordPress development for obtaining classification and sub-pages, wordpress_php tutorial

Source: Internet
Author: User

In the WordPress development to obtain the classification and sub-page function usage, detailed WordPress


Get_category
Get_category may we usually touch not much, but it is very useful, the function of the online description of the seemingly few, so today only for the official WordPress English document translation.

Function description
Gets the specified classification, returned as an array or as an object.

function uses

Get_category ($cat, $out, $filter)

Parameter description
$CAT: Category ID, or
$out return value type [OBJECT, Array_a, or Array_n]
$filter
function return value
This is mainly about the return value of the object type,
Have comments, please refer to them yourself.

StdClass Object (  //id Classification and label mixed  [term_id] + 5  //category name  [name] = + Cat name  //category alias  [slug] = > Cat  //n/a  [Term_group] + 0  //same term_id  [term_taxonomy_id] + 5  //taxonomy, i.e. category or label  [Taxonomy] = category  //Description  [description] +   //parent ID [parent  ] =  //n/a  [Count] + 0  //category ID  [cat_id] = 5  //n/a  [Category_count] + 0  //Same as Description  [Category_description] =   //same name  [cat_name] = category name  //Same as Slug  [category_ Nicename] = Category-name  //with parent  [category_parent] + 70)

Get_children ()
Let's take a look at the use of this function. Get_children is somewhat similar to the get_posts function, but different, the function is mainly used to retrieve or return, the parent article, the page under the Cong Wenzhang, attachment (important), a function.

I hope some of the content in this article will help you.

Get_children function meaning
Get_children () This function from the WordPress 2.0.0 began to have, mainly for: Retrieving attachments, versions, sub-pages and other information. The use of Get_children () and get_posts () is basically the same.

function usage

$args = Array (' post_parent ' = = $postid, ' post_type ' = ' attachment ', ' numberposts ' = 1, ' post_mime_type ' = ' Image ',); if ($images = Get_children ($args))

Parameter interpretation
$args [' numberposts ']
(integer) The number of child articles that need to be retrieved. Optional; Default value: 1 (unlimited)

$args [' Post_parent ']
(integer) passes the number of the journal or page to get its child articles. Pass null values to get the child articles of any article. Optional; Default value: 0 (any parent article?) )

$args [' Post_type ']
(character) The value in the Post_type column in the list of articles, such as attachments, pages, or modifications, or any of the keywords. Default value: Any

$args [' Post_status ']
(character) The value in the Post_status column in the list of articles, such as published, draft, or inherited, or keyword any. Default value: Any

$args [' Post_mime_type ']
(character) Full or incomplete MIME type, slice, video, video/mp4, matches the Post_mime_type field of the article.

$output
(constant) The variable type of an array item returned by any function in object, Array_a, Array_n. Optional; Default value: OBJECT
Summarize
Get_children (), generally in the subject, used to call the picture attachment in the article, that is, as long as you upload the image, even if your theme does not support the featured image or you do not set a featured image, we can use this function to upload the picture you uploaded in the article, Although this has some limitations, it is sufficient to complement the featured image. As for the other children of the content of the personal feeling is not very useful, and then because the general use of the article is not paged, so there is no demo to test the pagination. If you are studying the Get_children () function, hopefully this article will bring you good luck.

Articles you may be interested in:

    • A detailed description of the use of classification function wp_list_categories in WordPress
    • Get the number of articles under the specified category and its subcategories in WordPress
    • PHP functionality for adding categories and tags to media files in WordPress
    • Functions used in WordPress for obtaining information about articles and classifying links
    • The method to get the author and classified information of the article in WordPress

http://www.bkjia.com/PHPjc/1089940.html www.bkjia.com true http://www.bkjia.com/PHPjc/1089940.html techarticle in the development of WordPress to get the classification and sub-page function usage, detailed wordpress get_category get_category may we usually contact not much, but it is very useful, online this ...

  • 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.