Home › Forums › WoodMart support forum › Different layout for main categories
Different layout for main categories
- This topic has 16 replies, 3 voices, and was last updated 5 years, 2 months ago by Aizaz Imtiaz Awan.
-
AuthorPosts
-
October 10, 2019 at 8:17 am #149398
Laurence27220ParticipantHello,
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
October 10, 2019 at 11:00 am #149418
Aizaz Imtiaz AwanKeymasterHello,
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.
October 10, 2019 at 11:37 am #149433
Laurence27220ParticipantThank 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 …
October 10, 2019 at 12:42 pm #149448
Aizaz Imtiaz AwanKeymasterMost 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> </span> </span> </a></div></li>'; if( $show_subcategories ) { woodmart_show_category_ancestors(); } else { wp_list_categories( $list_args ); } echo '</ul>'; }
Best Regards.
October 15, 2019 at 8:10 am #150107
Laurence27220ParticipantThe 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.October 15, 2019 at 11:29 am #150168
Aizaz Imtiaz AwanKeymasterHello,
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.
October 15, 2019 at 3:11 pm #150241
Laurence27220ParticipantThat’s exactly what I want!
Unfortunately it does not work on my site.The code is installed. Should something be changed in this code?
Attachments:
You must be logged in to view attached files.October 15, 2019 at 6:05 pm #150279
aliyilmazParticipantI’m trying to remove it too https://prnt.sc/pjpfmq
October 15, 2019 at 6:25 pm #150284
aliyilmazParticipantOk,
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
October 16, 2019 at 8:58 am #150379
Aizaz Imtiaz AwanKeymasterHello,
@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.
October 16, 2019 at 9:03 am #150381
Laurence27220ParticipantThank 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.Attachments:
You must be logged in to view attached files.October 16, 2019 at 9:13 am #150388
Laurence27220ParticipantHello,
@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?October 16, 2019 at 1:49 pm #150470
Aizaz Imtiaz AwanKeymasterHello,
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.
October 17, 2019 at 10:30 am #150664
Laurence27220ParticipantBut 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
Attachments:
You must be logged in to view attached files.October 17, 2019 at 12:59 pm #150710
Aizaz Imtiaz AwanKeymasterMost 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.
October 22, 2019 at 10:21 am #151603
Laurence27220ParticipantI thank you for all your attention. I will test the reset or find the plugin that would be causing this problem.
October 22, 2019 at 10:54 am #151612
Aizaz Imtiaz AwanKeymasterHello,
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.
-
AuthorPosts
Tagged: categories, category, model, subcategories
- You must be logged in to create new topics. Login / Register