• I reckon this is pretty easy to do, just can’t seem to get it to happen for me.

    The follow code outputs a list of names in the order they were entered into the database. How would I get them to be output in alphabetical order instead:

    global $wpdb;
    $results = $wpdb->get_results('SELECT * FROM wp_terms INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_taxonomy_id WHERE taxonomy = "ngg_tag"');
    foreach ($results as $row) {
    echo "<li><a href=https://www.samplesite.co.uk/gallery/?gallerytag=";
    echo $row->slug;
    echo ">";
    echo $row->name;
    echo "</a> </li> ";
    }

    Any help or pointer would be greatly appreciated.

    To look at the code in action go to https://www.blackpigtattoo.co.uk and look at the ‘Tatto Gallery’ widget on the right hand side.

    Cheers,

    Michael

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘help needed sorting an array by alphabetical order’ is closed to new replies.