This article describes how to use the classification function wp_list_categories in WordPress, and lists the functions and writing of its main parameters, for more information, see the wp_list_categories function. it is a function used in WordPress to list the categories in the system. this function has many output control parameters and was suddenly asked by a friend today, so I sorted it out.
Because WordPress has built-in extended gadgets,
So we can display a category list in the sidebar or in other locations we want without any function,
Therefore, the wp_list_categories function is rarely used,
This function is similar to wp_list_bookmarks,
Wp_list_categories description
The wp_list_categories function is a function used in WordPress to list Classification links in the system.
If you are interested, you can go to the official documents.
Usage
<? Php wp_list_categories ($ args); $ args = array ('show _ option_all '=> '', // whether to list the category link 'orderby' => 'name ', // sort 'order' => 'asc 'by name, // ascending or descending order 'style' => 'list', // whether to use the list (ul> li) 'show _ count' => 0, // whether to display the number of articles 'hide _ empty' => 1, // whether no log category is displayed '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 _ type' => '', // rss type 'feed _ image' => '', // whether to display the rss image 'exclude' => '', // The ID of the excluded category, multiple use ', (Separated by commas) 'exclude _ tree' => '', // exclude category tree, that is, parent category and its subcategory 'include '=> '', // The included Category 'hierarchical '=> true, // whether to classify sub-and parent Categories 'title _ Lil' => _ ('category '), // the name of the list Title 'show _ option_none '=> _ ('No category'), // The title 'number' => null, // display the number of categories 'echo '=> 1, // whether to display, display or return the string 'demo' => 0, // hierarchy limit 'current _ category '=> 0, // add a non-existing category 'pad _ counts' => 0, // I do not understand this either. 'Taxonomy' => 'Category ', // The classifier used is 'Walker' => null // Is the class used for display (a complicated concept)?>
Regarding 'pad _ counts', I didn't understand what this parameter is,
If you are interested, you can study the official documentation of this parameter.
You can also use it against wp_list_bookmarks.
pad_counts(boolean) Calculates link or post counts by including items from 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
Use instance
Displays Classification links with IDs 3, 5, 9, and 16 in the order of names.
<?php wp_list_categories('orderby=name&include=3,5,9,16'); ?>
Displays the Poetry-titled classification list with IDs of 5, 9, and 23.
<?php wp_list_categories('include=5,9,23&title_li=' . __('Poetry') . '' ); ?>
Of course, you can write parameters as follows and integrate them into arrays.
<?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, 0 for no$title = ''; $args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'title_li' => $title);?>
<?php wp_list_categories( $args ); ?>
Taxonomy Classification is a concept relative to tags.