Is there any way that parent Categories also include number


Is there any way that parent Categories also include number of classifieds in the child categories ? For example, in the attached screen shot, I want "For Sale" Category show count of "(1)" instead of "(0)" since its child category (baby items) does have one classified.


  • Vinod Dalvi

    Hi Susan,

    I hope you are well today and thank you for your question.

    You can achieve this by adding the following code in the functions.php file of your child theme

    if ( ! function_exists( 'wp_get_cat_postcount' ) ) :
    function wp_get_cat_postcount($id) {
        $cat = get_term($id, 'classifieds_categories');
        $count = (int) $cat->count;
        $taxonomy = 'classifieds_categories';
        $args = array(
          'child_of' => $id,
        $tax_terms = get_terms($taxonomy,$args);
        foreach ($tax_terms as $tax_term) {
            $count += (int)$tax_term->count;
        return $count;

    And edit the following Classifieds plugin file on line number 58 as displayed below.

    Classifieds plugin file:

    Before Editing:

    if( isset( $options['general']['display_parent_count'] ) && $options['general']['display_parent_count'] ) $parent_count = sprintf(' (%d)', $category->count );
    else $parent_count = '';

    After Editing:

    if( isset( $options['general']['display_parent_count'] ) && $options['general']['display_parent_count'] ) $parent_count = sprintf(' (%d)', wp_get_cat_postcount($category->term_id) );
    else $parent_count = '';

    Note: You are making changes in the plugin file and these changes will be overwritten and lost when you update the plugin and you will have to make these changes again after plugin updation.

    Best Regards,
    Vinod Dalvi

  • Vinod Dalvi

    Hi Susan,

    To make the changes persistent after update try either using the attached small plugin or add the code from the plugin file in to the functions.php file of your theme.

    We can't say it as a bug because some members want the parent category count to display only the count of items attached to parent category.

    We can say it as a feature request so that plugin option will be developed to choose between these options.

    I will move this over to the features & feedback section. This way it can be considered for future development, and we can also see what other community members think about the feature request.

    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.