Home Forums WoodMart – Premium Template Different layout for main categories

This topic contains 16 replies, has 3 voices, and was last updated by Aizaz Imtiaz Awan Aizaz Imtiaz Awan 4 months ago.

Viewing 17 posts - 1 through 17 (of 17 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.



    That’s exactly what I want!
    Unfortunately it does not work on my site.

    The code is installed. Should something be changed in this code?

    You must be logged in to view attached files.


    I’m trying to remove it too https://prnt.sc/pjpfmq




    If you want to remove the yellow bar (alert message) for your empty category page. You can hide with custom css :

    body.term-83 .woocommerce-info {
    display: none;

    You should change “term-83” to your own class. You can get from there : https://prnt.sc/pjppsu



    @aliyilmaz I appreciate your help and thank you for sharing the solution that might help the others. But it’s not relevant to this topic.

    @laurence27220 I have provided you the CSS code to hide the empty categories from the Shop Page Title banner. Not from the categories menu. You need to check my screenshots that I have provided as before and after hiding those categories.

    And it is not possible to remove the empty categories from that menu which is in the header. You can only remove the empty categories manually from the Appearance >> Menus.

    Best Regards.



    Thank you for this information @aliyilmaz but my concern in the visibility of categories in the header where is the title

    As you can see in the photo, in the “Parcourir les catégories” menu, the “Bureau” link is expanded and you can see a number of categories. These do not have a product.
    I would like these categories to be visible under the title, as Aizaz showed me in the previous link (https://jumpshare.com/v/M6sSVSqMt9dxQR4E3cDI).
    The php code he offered me does not work at home.

    You must be logged in to view attached files.



    @Aizaz, as I just said, the link you gave me showing the empty categories is the result I want to get.

    The php code you gave me does not change anything on my site.
    Would there be a change I should make in this code?



    Yes, my provided code will not hide the empty categories from the search result.

    Because that code which I provided to you is just to hide the empty categories from the “Shop” page where all the products exists. And after the title the categories list is shown.

    Screenshot for better understanding: https://jmp.sh/TVjcUR9

    Best Regards.



    But then I do not need code because what I want is that the empty categories are visible but, on my site it is not the case.

    Between your photo and mine, we can see the difference. I made a mix of both.

    How come, since it’s automatic, I can not see the empty categories?
    I may have unchecked a box but which one?

    Anyway, thank you for the time you give me

    You must be logged in to view attached files.

    Most Welcome,

    As you said that you do not want to hide the empty categories.

    Actually those empty categories by default shown and can’t be hide with the theme options like as you said by unchecking an option.

    So it might be due to your custom code or may be due to some third party plugins.

    You can also try “Reset Default” option shown in the theme settings at the bottom of every page.

    Best Regards.



    I thank you for all your attention. I will test the reset or find the plugin that would be causing this problem.



    Sound’s Good!..

    We are thrilled that you loved your experience with XTEMOS, We put customer experience and satisfaction as our priority, and your words reaffirms the hard work we put in every day. So thanks for your kind words and we look forward to seeing you again.

    Let us know if there’s anything else we can do for you! You can always reach us at any time. We are always here to help you.

    Have a wonderful day.

    Best Regards.

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

You must be logged in to reply to this topic.