Home › Forums › Basel support forum › sort categegories in .basel-product-categories
sort categegories in .basel-product-categories
- This topic has 3 replies, 2 voices, and was last updated 5 years, 11 months ago by
Elise Noromit.
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
October 15, 2019 at 3:19 pm #150244
D0R1ANParticipantHello,
how do I sort the categories in .basel-product-categories (e.g. https://demo.xtemos.com/basel/product-category/watches/)?
It seems to be alphabetical in my shop instead of the order I set in the backend.
Please advise.Thanks,
DorianOctober 15, 2019 at 8:03 pm #150290
Elise NoromitMemberHello,
Unfortunately, there is no option to sort the categories in the shop page heading.
Best Regards
October 16, 2019 at 9:17 am #150389
D0R1ANParticipantHello,
no big deal if it’s not sortable via theme settings. Surely it must be sortable somehow, though.
Would you mind asking your programmer how to set the ‘orderby’ => ‘menu_order’ there?Thank you.
DorianOctober 16, 2019 at 2:24 pm #150486
Elise NoromitMemberHello,
Please insert this code into functions.php of the child theme:
function basel_product_categories_nav() { global $wp_query, $post; $show_subcategories = basel_get_opt( 'shop_categories_ancestors' ); $show_categories_neighbors = basel_get_opt( 'show_categories_neighbors' ); $list_args = array( 'taxonomy' => 'product_cat', 'hide_empty' => false ); // Menu Order $list_args['orderby'] = 'menu_order'; // 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; $list_args['walker'] = new BASEL_Walker_Category(); if ( basel_is_shop_on_front() ) { $shop_link = home_url(); } else { $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 '<a href="#" class="basel-show-categories">' . esc_html__('Categories', 'basel') . '</a>'; echo '<ul class="basel-product-categories">'; echo '<li class="cat-link shop-all-link"><a href="' . esc_url( $shop_link ) . '">' . esc_html__('All', 'basel') . '</a></li>'; if( $show_subcategories ) { basel_show_category_ancestors(); } else { wp_list_categories( $list_args ); } echo '</ul>'; }
Best Regards
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to create new topics. Login / Register