Visualizzazione 0 filoni di risposte
Visualizzazione 0 filoni di risposte
- Devi essere connesso per rispondere a questo topic.
Email: info@wpitaly.it
Home › Forum › Plugin e temi di WP › combobox dinamiche
ciao a tutti,
sto cercando di creare delle combobox dinamiche in wordpress, che a seconda della categoria scelta mi carichino i valori dei campi personalizzati che ho già inserito.
Ho già elaborato la funzione per selezionare i valori ma non so come implementarlo con wordpress o ajax o jquery… qualcuno sa darmi qualche suggerimento?
$querystr3 = "
SELECT DISTINCT wpostmeta.meta_value
FROM $wpdb->posts wposts
LEFT JOIN $wpdb->postmeta wpostmeta ON wposts.ID = wpostmeta.post_id
LEFT JOIN $wpdb->term_relationships ON (wposts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE wpostmeta.meta_key = 'alimentazione'
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->term_taxonomy.term_id IN(6)
ORDER BY wpostmeta.meta_value ASC
";
$pageposts = $wpdb->get_results($querystr,ARRAY_A);
questa è la query per selezionare i valori unici di un campo personalizzato data la categoria
e questa è il codice per leggere il mio array di dati
<select name="pippo">
<?php //global $post; ?>
<?php foreach ($pageposts3 as $chiave3): ?>
<?php //setup_postdata($post); ?>
<option value="<?php echo $chiave3['meta_value']; ?>" ><?php echo $chiave3['meta_value']; ?></option>
<?php endforeach; ?>
</select>
per ogni categoria selezionata dovrebbero caricarsi i dati su altri 3 combobox in modo da fare una query finale tra:
– categoria
– campo personalizzato 1 della categoria scelta
– campo personalizzato 2 della categoria scelta
– campo personalizzato 3 della categoria scelta
WPItaly - Copyright Creative Commons: CC BY-NC-SA 4.0