I have recently purchased a WordPress theme,and built a website with directory listing. On the Homepage there is a listing with locations, and at the moment they are listed in ascending order.

I have managed to figure out where is the script which controls this section, what I would like to do is to display the locations where the highest number of adverts are.

This is the bit of code which I believe is displaying it:

$location_counter = $redux_demo['home-location-counter'];

$locations = get_terms(



        'parent' => 0,

        'order'=> 'ASC',

        'number'=> $location_counter,

        'empty'=> 1




foreach ($locations as $location) {



How could I re-write this section to show the locations according to the highest number of adverts added to a particular city? If anyone could give me an advice, it would be great. I have tried with the support, but they were not very helpful.


You can get what you want by doing this:

'order'=> 'ASC', 'orderby' => 'count'

This will order the result of get_terms by number of posts each term has

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.