Visualizzazione 3 filoni di risposte
Visualizzazione 3 filoni di risposte
- Devi essere connesso per rispondere a questo topic.
Email: info@wpitaly.it
Home › Forum › Plugin e temi di WP › Lista delle categorie in un array php…
Esiste una funzione che consente di avere l’elenco delle categorie del blog in una variabile-array php, senza dover recuperarle “a mano” dal db?
Insomma, mi servirebbe una specie di list_cats() che però, invece si stampare l’elenco a video, return-i le categorie (e le sottocategorie) in un array (e sottoarray) gerarchico: mi sembra di non aver visto argomenti di list_cats() che mi consentano di fare ciò che chiedo (‘recurse’ non sembra andar bene: non restituisce un array gerarchico, ma una “disordinata” string).
Possibile che non abbiano dato la possibilità di mettere in un array le categorie?
Saluti,
Antonio
prova a vedere in wp-includes/template-functions-category.php
o altrimenti questo è l’array
$array_cat = $db->get_results("SELECT * FROM $tablecategories");
print_r($array_cat);
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.
Ho sostituito $db con $wpdb e funziona.
sଠscusami, è che ultimamente sto usando parecchio ezSQL, che appunto usa $db
invece di $wpdb
, di qui il lapsus.
Non credo che ci sia una funzione pronta per ottenere ciò che cerchi… pero’ puoi provare a chiedere nella wp-hackers mailing list
WPItaly - Copyright Creative Commons: CC BY-NC-SA 4.0