Sort taxonomy by post


I search in internet and cannot found solution to my problem. WordPress has any solution to order taxonomy by post. For example: I have hotels from different countries. If user enter to the hotel in Uzbekistan taxonomy should come firstly Uzbekistan than other countries.

<div class="left_widget">
    <h2 class="second_title"><?=pll__('Destinations')?></h2>
        <ul class="left_menu">
            <li><a href="<?=get_permalink( get_id_by_slug('hotels-'.currlang()) )?>"><?=pll__('All Hotels')?></a></li>
            $categories = get_terms('destination', 'orderby=rand&hide_empty=0'); 


            foreach ($categories as $cat):
            <li><a href="<?=get_permalink( get_id_by_slug('hotels-'.currlang()) )?>?h-destination=<?=$cat->name;?>"><?=$cat->name;?></a></li>

Read more here: Sort taxonomy by post

Leave a Reply

Your email address will not be published. Required fields are marked *