php - output wordpress list categories with count by name the parent category -
i try output wordpress categories count @ end of each category's name input parent category in code somewhere.
the result of code down below display categories count of posts @ end, display categories.
ex: have parent category name "alpha", , child categories name are, category a, category b, category c, category d
i want output display:
-category (5)
-category b (2)
-category c (6)
-category d (7)
<?php $variable = wp_list_categories( array( 'show_count' => true, 'orderby' => 'name', 'style' => 'none' ) ); echo $variable; ?>
display current category wise child category total post count
<?php $category_object = get_queried_object(); $current_category_taxonomy = $category_object->taxonomy; $current_category_term_id = $category_object->term_id; $current_category_name = $category_object->name; $args = array( 'child_of' => $current_category_term_id, 'current_category' => $current_category_term_id, 'depth' => 0, 'echo' => 1, 'exclude' => '', 'exclude_tree' => '', 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'hide_empty' => 0, 'hide_title_if_empty' => false, 'hierarchical' => true, 'order' => 'asc', 'orderby' => 'name', 'separator' => '', 'show_count' => 1, 'show_option_all' => '', 'show_option_none' => __( 'no categories' ), 'style' => 'list', 'taxonomy' => 'category', 'title_li' => __( $current_category_name ), 'use_desc_for_title' => 0, ); wp_list_categories($args); ?>
Comments
Post a Comment