Home Forums WoodMart – Premium Template Different layout for main categories

This topic contains 5 replies, has 2 voices, and was last updated by Aizaz Imtiaz Awan Aizaz Imtiaz Awan 3 hours, 33 minutes ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #149398


    I have two requests:

    1 / I would like to display in their main categories their subcategories.
    it does not change anything when I choose the type of display “subcategory”.

    2 / So, when I click on one of these pages main categories appears a line indicating that there is no product corresponding to my selection. I would like this pop-up does not appear.

    How can I solve both of these problems?

    Thanking you



    If you want to display the subcategories inside the main categories then enable the “Show current category ancestors” from Theme Settings >> Shop >> SIDEBAR & PAGE TITLE.

    Also in your second point you asking that you do not want that popup (which is drop down in actual) for that you have to enable the “Show current category ancestors” so in the category page shown that line if there is no sub categories as in the screenshot: https://jmp.sh/e53DOew

    While creating a sub category from Products >> Categories. You need to make sure that you select a Parent category for this child.

    You are using an older version of theme and outdated theme requires plugins. Kindly also update your theme as well as plugins.

    Best Regards.



    Thank you for your answer Aizaz.
    Actually, activating the option “Show current category ancestors” will solve part of my problem but if there is no product in a subcategory then it is not visible and, as you show on your image, it is indicated that there is no product.
    All my subcategories have their parent selected and my theme and extensions are up to date 😉

    It seemed to me to have seen the possibility to hide or make visible categories that have no product but I can not find where it is …


    Most Welcome,

    In my screenshot that I provided to you displaying a message that “No product categories exist.” not only the products. It’s about the product categories.

    If the product category does not have any products inside it then it does not shown any message it just simply shown the empty category page as in the screenshot: https://jmp.sh/nMbE70G

    Also by default the empty product category does not hidden. But you can hide the categories that have no products. Try to paste the below code in funtions.php:

    function woodmart_product_categories_nav() {
    		global $wp_query, $post;
    		$show_subcategories = woodmart_get_opt( 'shop_categories_ancestors' );
    		$show_categories_neighbors = woodmart_get_opt( 'show_categories_neighbors' );
    		$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['show_count']       = woodmart_get_opt( 'shop_products_count' );
    		$list_args['walker'] = new WOODMART_Walker_Category();
    		$class = ( woodmart_get_opt( 'shop_products_count' ) ) ? 'has-product-count' : 'hasno-product-count';
    		$shop_link = get_post_type_archive_link( 'product' );
    		include_once( WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php' );
    		if( is_object( $current_cat ) && !get_term_children( $current_cat->term_id, 'product_cat' ) && $show_subcategories && !$show_categories_neighbors ) return;
    		echo '<div class="woodmart-show-categories"><a href="#">' . esc_html__('Categories', 'woodmart') . '</a></div>';
    		echo '<ul class="woodmart-product-categories ' . esc_attr( $class ). '">';
    		echo '<li class="cat-link shop-all-link"><div class="category-nav-link"><a href="' . esc_url( $shop_link ) . '">
    				<span class="category-summary">
    					<span class="category-name">' . esc_html__('All', 'woodmart') . '</span>
    					<span class="category-products-count">
    						<span class="cat-count-label">' . esc_html__('products', 'woodmart') . '</span>
    		if( $show_subcategories ) {
    		} else {
    			wp_list_categories( $list_args );
    	echo '</ul>';

    Best Regards.



    The code does not change anything.

    You say that by default the categories are visible when there are no products and we can hide them.
    Where can we do it? I may have checked a box by mistake. I can not find the place where I can do it.



    With the theme options we can not hide the empty product categories.

    I used the same code in my site funtions.php and it works just fine:

    Screenshot before hiding the empty categories: https://jmp.sh/DUjI4QR

    Screenshot after hiding: https://jmp.sh/Ger8vFn

    Best Regards.

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

You must be logged in to reply to this topic.