0

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:

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

$locations = get_terms(

    'location', 

    array(

        'parent' => 0,

        'order'=> 'ASC',

        'number'=> $location_counter,

        'empty'=> 1

    )   
);

//print_r($locations);

//exit();

foreach ($locations as $location) {

    if(!empty($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.

closed as off-topic by Howdy_McGee, kaiser Apr 7 '16 at 20:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

0

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

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