My products are sort by menu_order, but I would like to sort category name too. I tried a few plugins and all doesn’t works.
Code, which display category name and products list:
<?php $custom_terms = get_terms('product-cat');
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array(
'post_type' => 'product',
'posts_per_page' => 9999,
'orderby' => 'menu_order',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'product-cat',
'field' => 'slug',
'terms' => $custom_term->slug
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts()) {
echo '<li><h3>'.$custom_term->name.'</h3>';
echo '<ul>';
while($loop->have_posts()) : $loop->the_post();
echo '<li><a href="'.get_permalink().'" title="' . get_the_title() .'">'.get_the_title().'</a></li>';
endwhile;
echo '</ul>';
echo '</li>';
}
} ?>
Thanks for reply.
Regards.