Custom post type category sort using get_terms()
(orderby doesn't work here!)
// Add product category sort
add_action( 'genesis_before_loop', 'orc_product_category_sort' );
function orc_product_category_sort() {
if ( is_post_type_archive( 'product' ) OR is_tax( 'product_cat' ) ) {
$portfolio = site_url('/shop/');
echo '<a name="sort"></a>';
echo '<div class="category-sort">';
echo '<div class="entry-categories">Sort by: <a href="' . $portfolio . '#sort" alt="Show all portfolio categories">Show All</a>';
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false
);
$terms = get_terms( 'product_cat', $args );
foreach ( $terms as $term ) {
echo '<a href="' . get_term_link( $term ) . '#sort">' . $term->name . '</a>';
}
echo '</div>';
echo '</div>';
$term_name = single_cat_title( $prefix = '', $display = false );
echo '<h1 class="entry-title" itemprop="headline">' . $term_name . '</h1>';
} // if
}