Home Forums Basel – Premium Template Hiding Empty Shopping Categories

This topic contains 1 reply, has 2 voices, and was last updated by Artem Temos Artem Temos 4 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8766

    netbaron00
    Participant

    First and foremost – awesome theme & thank you for all the hard work that went into it!

    I have a slight issue / question: When viewing the Woocommerce category pages (such as the “shop” page I have the “Categories menu in page heading” turned on and it is displaying. However it is also displaying empty categories. Is there a way to prevent it from displaying categories that are yet to be filled in, or even down the road that I do not intend people having direct navigation to?

    Thanks for any help you can provide!

    #8771
    Artem Temos
    Artem Temos
    Keymaster

    Hello,

    Thank you so much purchasing our theme and contacting our support center.

    You can do this modifying this function a bit. Just place the following snippet to your child theme functions.php file

    function basel_product_categories_nav() {
    	global $wp_query, $post;
    
    	$show_subcategories = basel_get_opt( 'shop_categories_ancestors' );
    
    	$list_args = array(  
    		'taxonomy' => 'product_cat', 
    		'hide_empty' => true 
    	);
    
    	// Menu Order
    	$list_args['menu_order'] = false;
    	$list_args['menu_order'] = 'asc';
    
    	// Setup Current Category
    	$current_cat   = false;
    	$cat_ancestors = array();
    
    	if ( is_tax( 'product_cat' ) ) {
    
    		$current_cat   = $wp_query->queried_object;
    		$cat_ancestors = get_ancestors( $current_cat->term_id, 'product_cat' );
    
    	}
    
    	$list_args['depth']            = 5;
    	$list_args['child_of']         = 0;
    	$list_args['title_li']         = '';
    	$list_args['hierarchical']     = 1;
    	$list_args['use_desc_for_title']= false;
    
    	$shop_link = get_post_type_archive_link( 'product' );
    
    	include_once( WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php' );
    
    	echo '<a href="#" class="basel-show-categories">' . __('Categories', 'basel') . '</a>';
    
    	echo '<ul class="basel-product-categories">';
    	
    	echo '<li class="cat-link shop-all-link"><a href="' . esc_url( $shop_link ) . '">' . __('All', 'basel') . '</a></li>';
    
    	if( $show_subcategories ) {
    		basel_show_category_ancestors();
    	} else {
    		wp_list_categories( $list_args  );
    	}
    
    	echo '</ul>';
    }

    Kind Regards
    XTemos Studio

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.