Function Reference: geodir_cpt_categories_child_cats
Summary
Get the child categories content.
Parameters
- $parent_id
- (int) (required) Parent category id.
- Default: None
- $cpt
- (string) (required) The post type.
- Default: None
- $hide_empty
- (bool) (required) If true then filter the empty categories.
- Default: None
- $show_count
- (bool) (required) If true then category count will be displayed.
- Default: None
- $sort_by
- (string) (required) Sorting order for categories.
- Default: None
- $max_count
- (bool|string) (required) Max no of sub-categories count to display.
- Default: None
- $max_level
- (bool|string) (required) Max depth level sub-categories to display.
- Default: None
- $term_icons
- (array) (required) Array of terms icons url.
- Default: None
- $depth
- (int) (required) Category depth level.
- Default: 1
Return Values
- (string)
- Html content.
Change Log
Since: 1.5.4
Filters
‘geodir_category_term_link’ [Line: 544]
Source File
geodir_cpt_categories_child_cats() is located in geodirectory-widgets/geodirectory_cpt_categories_widget.php [Line: 510]
Source Code
function geodir_cpt_categories_child_cats($parent_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth = 1) { $cat_taxonomy = $cpt . 'category'; $orderby = 'count'; $order = 'DESC'; if ($sort_by == 'az') { $orderby = 'name'; $order = 'ASC'; } if ($max_level != 'all' && $depth > (int)$max_level ) { return ''; } $child_cats = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_id, 'number' => $max_count)); if ($hide_empty) { $child_cats = geodir_filter_empty_terms($child_cats); } if (empty($child_cats)) { return ''; } if ($sort_by == 'count') { $child_cats = geodir_sort_terms($child_cats, 'count'); } $content = '
- ';
$depth++;
foreach ($child_cats as $category) {
$term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : '';
$term_icon_url = $term_icon_url != '' ? ' ' : '';
$term_link = get_term_link( $category, $category->taxonomy );
/** Filter documented in geodirectory-functions/general_functions.php **/
$term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt );
$count = $show_count ? ' (' . $category->count . ')' : '';
$content .= '
- '; $content .= '' . $term_icon_url . $category->name . $count . ' '; $content .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth); } $content .= '