I need to sort and paginate custom taxonomy post types. i have a page where i have next and previous link. on clicking next and previous link next or previous brand(custom taxonomy) should load. I have achieved this so far
$terms = get_the_terms( get_the_ID(), 'brand' );
if($terms) {
$BrandId=$terms[0]->term_id;
$nextBrandId=$BrandId+1;
$prevBranId=$BrandId-1;
$next=get_term_by('id', $nextBrandId, 'brand' );
$prev=get_term_by('id', $prevBranId, 'brand' );
//echo '<pre>';
echo $next->slug;
echo $prev->slug;
// echo '</pre>';
}
I am getting next and previous brand slug by id and they are showing randomly (if i talk in alphabetic order).
Please tell me how can i show next and previous link that are sorted by alphateicallhy.
For eg I have following brands
Versace, Valentino, Armani, Rado, CK, Tissot
If currently i am at Tissot and click next then i should go to Valentino. If i am at Tissot and click prev then i should go to Rado.
usort
orwp_get_post_terms
to sort your post terms by name