I need to hide the count of how many listings I have in each subcategory

Using the Directory plugin on http://www.bcosc.com/memberlistings/ I need to be able to display all the categories and 5 subcategories without showing the count of the listings in each subcategory

example of what is shown now:
ADVERTISING & MEDIA
News (1)
Photographers (1)

example of what I want shown:
ADVERTISING & MEDIA
News
Photographers

Any help would be much appreciated!

  • Vinod Dalvi
    • WP Unicorn

    Hi @Andrea,

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

    To hide the category count you can just add the following code in the below Directory plugin file on line number 56.

    Plugin File:
    directory\core\template-tags.php

    Before editing code:
    'show_count' => 1,

    After editing code:
    'show_count' => 0,

    Kind Regards,
    Vinod Dalvi

  • yehuda
    • Design Lord, Child of Thor

    Hi Andrea,

    How are you ?

    Roll back the changes you made to the core plugin file and
    try to put this in your theme functions.php file:

    remove_shortcode('dr_list_categories');
    add_shortcode( 'dr_list_categories', 'rcc_list_categories_sc' );
    
    function rcc_list_categories_sc( $atts, $content = null ) {
    	extract( shortcode_atts( array(
    	'style' => '', //list, grid
    	), $atts ) );
    
    	if($style == 'grid') $result = '<div class="dr_list_grid">';
    	elseif($style == 'list') $result = '<div class="dr_list">';
    	else $result = "<div>";
    
    	$result .= rcc_the_dr_categories_home( false, $atts );
    
    	$result .= "</div><!--.dr_list-->";
    
    	return $result;
    }
    
    function rcc_the_dr_categories_home( $echo = true ){
    
    	//get plugin options
    	$options  = get_option( DR_OPTIONS_NAME );
    
    	$cat_num                = ( isset( $options['general']['count_cat'] ) && is_numeric( $options['general']['count_cat'] ) && 0 < $options['general']['count_cat'] ) ? $options['general']['count_cat'] : 10;
    	$sub_cat_num            = ( isset( $options['general']['count_sub_cat'] ) && is_numeric( $options['general']['count_sub_cat'] ) && 0 < $options['general']['count_sub_cat'] ) ? $options['general']['count_sub_cat'] : 5;
    	$hide_empty_sub_cat     = ( isset( $options['general']['hide_empty_sub_cat'] ) && is_numeric( $options['general']['hide_empty_sub_cat'] ) && 0 < $options['general']['hide_empty_sub_cat'] ) ? $options['general']['hide_empty_sub_cat'] : 0;
    
    	$taxonomies = array_values(get_taxonomies(array('object_type' => array('directory_listing'), 'hierarchical' => 1)));
    
    	$args = array(
    	'parent'       => 0,
    	'orderby'      => 'name',
    	'order'        => 'ASC',
    	'hide_empty'   => 0,
    	'hierarchical' => 1,
    	'number'       => $cat_num,
    	'taxonomy'     => $taxonomies,
    	'pad_counts'   => 1
    	);
    
    	$categories = get_categories( $args );
    
    	$output = '<div id="dr_list_categories" class="listing_category" >' . "\n";
    	$output .= "<ul>\n";
    
    	foreach( $categories as $category ){
    
    		$output .= "<li>\n";
    		$output .= '<h2><a href="' . get_term_link( $category ) . '" title="' . __( 'View all posts in ', DR_TEXT_DOMAIN ) . $category->name . '" >' . $category->name . "</a> </h2>\n";
    
    		$output .= '<div class="term-list">';
    
    		$args = array(
    		'show_option_all'    => '',
    		'orderby'            => 'name',
    		'order'              => 'ASC',
    		'style'              => 'none',
    		'show_count'         => 0,
    		'hide_empty'         => $hide_empty_sub_cat,
    		'use_desc_for_title' => 1,
    		'child_of'           => $category->term_id,
    		'feed'               => '',
    		'feed_type'          => '',
    		'feed_image'         => '',
    		'exclude'            => '',
    		'exclude_tree'       => '',
    		'include'            => '',
    		'hierarchical'       => true,
    		'title_li'           => '',
    		'show_option_none'   => '', //sprintf('<span class="dr-empty">%s</span>', __('No categories', DR_TEXT_DOMAIN ) ),
    		'number'             => $sub_cat_num,
    		'echo'               => 0,
    		'depth'              => 1,
    		'current_category'   => 0,
    		'pad_counts'         => 1,
    		'taxonomy'           => $category->taxonomy,
    		'walker'             => null
    		);
    		$output .=   wp_list_categories($args);
    
    		$output .= "</div><!-- .term-list -->\n";
    
    		$output .= "</li>\n";
    
    	}
    
    	$output .= "</ul>\n";
    	$output .= "</div><!-- .dr_list_categories -->\n";
    
    	return $output;
    }
    /**
    Remove WPMU Dev Directory plugin Category Count
    END
    */
  • Vinod Dalvi
    • WP Unicorn

    Hi @yehuda,

    Thank you for chiming in here and sharing the solution.

    Hi @Andrea,

    I have created a feature request to add hook in the plugin so that it can be changed easily from the child theme. this feature may be added in future version of plugin.

    In the meanwhile you can just use the solution posted by @yehuda in his previous reply.

    Cheers,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.