wp_list_categories [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Display or retrieve the HTML list of categories.
The list of arguments is below: 'show_option_all' (string) - Text to display for showing all categories. 'orderby' (string) default is 'ID' - What column to use for ordering the categories. 'order' (string) default is 'ASC' - What direction to order categories. 'show_count' (bool|int) default is 0 - Whether to show how many posts are in the category. 'hide_empty' (bool|int) default is 1 - Whether to hide categories that don't have any posts attached to them. 'use_desc_for_title' (bool|int) default is 1 - Whether to use the description instead of the category title. 'feed' - See {@link get_categories()}. 'feed_type' - See {@link get_categories()}. 'feed_image' - See {@link get_categories()}. 'child_of' (int) default is 0 - See {@link get_categories()}. 'exclude' (string) - See {@link get_categories()}. 'exclude_tree' (string) - See {@link get_categories()}. 'echo' (bool|int) default is 1 - Whether to display or retrieve content. 'current_category' (int) - See {@link get_categories()}. 'hierarchical' (bool) - See {@link get_categories()}. 'title_li' (string) - See {@link get_categories()}. 'depth' (int) - The max depth.
Source
<?php
function wp_list_categories( $args = '' ) {
$defaults = array(
'show_option_all' => '', 'show_option_none' => __('No categories'),
'orderby' => 'name', 'order' => 'ASC',
'style' => 'list',
'show_count' => 0, 'hide_empty' => 1,
'use_desc_for_title' => 1, 'child_of' => 0,
'feed' => '', 'feed_type' => '',
'feed_image' => '', 'exclude' => '',
'exclude_tree' => '', 'current_category' => 0,
'hierarchical' => true, 'title_li' => __( 'Categories' ),
'echo' => 1, 'depth' => 0,
'taxonomy' => 'category'
);
$r = wp_parse_args( $args, $defaults );
if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
$r['pad_counts'] = true;
if ( true == $r['hierarchical'] ) {
$r['exclude_tree'] = $r['exclude'];
$r['exclude'] = '';
}
if ( !isset( $r['class'] ) )
$r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
extract( $r );
if ( !taxonomy_exists($taxonomy) )
return false;
$categories = get_categories( $r );
$output = '';
if ( $title_li && 'list' == $style )
$output = '<li class="' . esc_attr( $class ) . '">' . $title_li . '<ul>';
if ( empty( $categories ) ) {
if ( ! empty( $show_option_none ) ) {
if ( 'list' == $style )
$output .= '<li>' . $show_option_none . '</li>';
else
$output .= $show_option_none;
}
} else {
if ( ! empty( $show_option_all ) ) {
$posts_page = ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) ? get_permalink( get_option( 'page_for_posts' ) ) : home_url( '/' );
$posts_page = esc_url( $posts_page );
if ( 'list' == $style )
$output .= "<li><a href='$posts_page'>$show_option_all</a></li>";
else
$output .= "<a href='$posts_page'>$show_option_all</a>";
}
if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
$current_term_object = get_queried_object();
if ( $r['taxonomy'] == $current_term_object->taxonomy )
$r['current_category'] = get_queried_object_id();
}
if ( $hierarchical )
$depth = $r['depth'];
else
$depth = -1; // Flat.
$output .= walk_category_tree( $categories, $depth, $r );
}
if ( $title_li && 'list' == $style )
$output .= '</ul></li>';
$output = apply_filters( 'wp_list_categories', $output, $args );
if ( $echo )
echo $output;
else
return $output;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- wp_list_categories - WordPress Codex
NOTE: wp_list_categories() works in much the same way as the ...
codex.wordpress.org - WordPress › Support » Tags — wp_list_categories()
WordPress › Support » wp_list_categories(). 12…5Next » ...
wordpress.org - How to customize wp_list_categories output
Jul 15, 2011 ... Wordpress uses a special class for various tree-like structures called a Walker. It's used for viewing categor.
www.ultimatewebtips.com - wp_list_categories how to alter it? | ThemeForest Community Forums
How can I alter what outputs wp_list_categories? I'm need to put some menu items under particular category and those are simple links, not ...
themeforest.net
Gebruikersdiscussies [ wordpress.org ]
- ichiz on "wp_list_categories / custom post type / if conatain taxonomy"
- alchymyth on "wp_list categories doesnt display sub categories ?"
- Fatih Toprak on "wp_list categories doesnt display sub categories ?"
- Fatih Toprak on "wp_list categories doesnt display sub categories ?"
- alchymyth on "wp_list categories doesnt display sub categories ?"
- Fatih Toprak on "wp_list categories doesnt display sub categories ?"
- Fatih Toprak on "wp_list categories doesnt display sub categories ?"
- alchymyth on "wp_list categories doesnt display sub categories ?"
- Fatih Toprak on "wp_list categories doesnt display sub categories ?"
- hozyali on "having problem with wp_list_categories"