Home › Forum › Problemi Vari con WP › Resettare get_post()
-
AutorePost
-
-
19 Dicembre 2011 alle 9:35 #20091m4rko80Partecipante
Buongiorno a tutti, sto cercando di usare tramite funzioni native get_post per() ricavare dei post in base ad una sottocatecategoria ma non mi torna qualcosa.
In pratica eseguo 4 query passando parametri e nello specifico per ogni query la sottocategoria cambia.
La cosa che non mi ritorna e’ il risultato ossia sempre uguale alla prima eseguita.
Ho provato ad usare anche wp_reset_query() dopo ogni richiamo ma il risultato non cambia.
Premesso che da programmatore la query scritta manualmente corrisponderebbe ad una cosa simile:
Faccio 4 query in quanto non ho trovato la possibilita’ di usare una distinct() in sql.
In pratica ho la categoria NATALE e le 4 sotto categorie, dovrei estrarre le ultime 4 inserite ma ognuna con sottocategoria diversa.
Come resetto il risultato di get_post() ?
Attualmente ho provato con
$args = array(
'numberposts' => 1,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'post_status' => 'publish' );
$args='categoria_test_1';//dove questo cambia sempre
$myposts = get_posts( $args );
wp_reset_query();
Ringrazio per evenutali riposte.EDIT: attualmente ho risolto utilizzando WP_Query(); se non e’ la soluzione migliore sono ben accetti consigli
-
7 Gennaio 2012 alle 17:29 #91578
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.