Home Forums WoodMart support forum Page Title Categories Not Ordering After Update to Woodmart 4.2

Page Title Categories Not Ordering After Update to Woodmart 4.2

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #153989

    mv
    Participant

    Hello there,

    The Categories in the Page Title are no longer ordering correctly after updating to Woodmart 4.2. They order alphabetically instead of honouring the manual category ordering. It seems to be related to the “woodmart_product_categories_nav” in template-tags.php. Is there a way to specific the order of these categories any more?

    Thank you

    #154027

    Artem Temos
    Keymaster

    Hello,

    We have added a filter for that order and accidentally changed the default value. You can change it with the following code added to the functions.php file in the child theme

    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' => false,
    		);
    		$order_by = apply_filters( 'woodmart_product_categories_nav_order_by', 'menu_order' );
    		$order = apply_filters( 'woodmart_product_categories_nav_order', 'asc' );
    		if ( 'menu_order' === $order_by ) {
    			$list_args['menu_order'] = false;
    			$list_args['menu_order'] = $order;
    		} else {
    			$list_args['order'] = $order;
    			$list_args['orderby'] = $order_by;
    		}
    		// 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';
    		if ( woodmart_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 '<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"><a class="category-nav-link" 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></li>';
    		if( $show_subcategories ) {
    			woodmart_show_category_ancestors();
    		} else {
    			wp_list_categories( $list_args );
    		}
    		echo '</ul>';
    	}

    Regards

    #154718

    mv
    Participant

    Thank you. This solved our issue.

    #154778

    Artem Temos
    Keymaster

    Great, you are welcome.

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

The topic ‘Page Title Categories Not Ordering After Update to Woodmart 4.2’ is closed to new replies.