Detailed explanation of the use _php skills of classification function wp_list_categories in WordPress

Source: Internet
Author: User
Tags sorted by name

Wp_list_categories function is used in WordPress to list the classification of the system functions, the function has a lot of control output parameters, today suddenly was asked by a friend, so I probably sorted it out.

Because of the built-in extended gadget features in WordPress,
So we can display a list of categories in the sidebar or wherever we want without any function.
So the wp_list_categories function is rarely used,
The function is somewhat similar to Wp_list_bookmarks,

Wp_list_categories description
the Wp_list_categories function is a function of WordPress to list the classification links in the system.
The original English is not on, interested can go to see the official document.

Usage

<?php wp_list_categories ($args); $args = Array (' Show_option_all ' => ',//whether to list category links ' by ' => ' name ',//' order ' by name ' => ' ASC ',//L , descending ' style ' => ' list ',//whether to use the list (Ul>li) ' Show_count ' => 0,//whether to show the number of articles ' Hide_empty ' => 1,//whether there is no log Category ' Use_desc_for_title ' => 1,//whether to display the category description ' child_of ' => 0,//whether to restrict the subcategory ' feed ' => ',//whether to display RSS ' Feed_ty PE ' => ',//rss type ' feed_image ' => ',//whether to display RSS picture ' Exclude ' => ',//exclude category ID, multiple use ', (English comma) ' delimited ' exclud E_tree ' => ',//excludes the classification tree, that is, the parent category and its sub category ' include ' => ',//Includes the category ' Hierarchical ' => true,//whether to rank the child, parent classification ' TITL E_li ' => __ (' Categories '), the name of the list title ' Show_option_none ' => __ (' no Categories '),//The title ' number ' displayed when no classification > null,//Display the number of categories ' echo ' => 1,//display, display or return string ' depth ' => 0,//level limit ' current_category ' => add Add a no category ' Pad_counts ' => 0,//This I don't understand ' taxonomy ' => ' category ',//using the taxonomy ' walker ' => null//classes for display (very complex concepts)?>
 

As for ' pad_counts ', I don't understand what this parameter is for,
If you are interested you can study the official documentation for this parameter.
You can also compare wp_list_bookmarks to use.

Pad_counts
(Boolean) calculates link or post counts by including the items from the child categories. If show_counts and hierarchical are true this is automatically set to true. This parameter added at Version 2.9 Valid values:
1 (true)
0 (false) –default

Working with instances
Display category links that include ID 3,5,9,16, sorted by name

<ul>
<?php wp_list_categories (' orderby=name&include=3,5,9,16 ');?> 
</ul>

Include a list of categories with ID 5,9,23 that poetry as headings

<ul>
<?php wp_list_categories (' include=5,9,23&title_li= 
 

Of course you can also write parameters as follows, consolidating the parameters into an array.

<?php 
$taxonomy   = ' genre ';
$orderby   = ' name '; 
$show _count  = 0;   1 for Yes, 0 for no
$pad _counts  = 0;   1 for Yes, 0 for no
$hierarchical = 1;   1 for Yes and 0 for no
$title    = ';
 
$args = Array (
 ' taxonomy '   => $taxonomy,
 ' by '   => $orderby,
 ' show_count '  = > $show _count,
 ' pad_counts '  => $pad _counts,
 ' hierarchical ' => $hierarchical,
 ' Title_ Li '   => $title
);
? >
 
<ul>
<?php wp_list_categories ($args);?>
</ul>

The taxonomy taxonomy is relative to the label (tag) concept.

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.