Anzitutto, grazie.
Ho sostituito $db con $wpdb e funziona.
Però mi dà semplicemente la lista di tutte le categorie. Mentre io volevo un array gerarchico, cioè con le sottocategorie come sottoarray di ogni categoria. Vedrò di usare category_parent, anche se pensavo esistesse qualcosa di già pronto…
Grazie,
A.