Lavorare con query_posts (array e corde di query)
-
31-10-2019 - |
Domanda
Sto cercando di usare la query di ricerca insieme a una serie di argomenti per restringere i risultati di ricerca, ma non sto fallendo orribilmente. Questo è quello che ho finora.
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query_string = 's=test&category=wordpress'
$s_array = array(
'post_type' => 'blog',
'caller_get_posts' => 1,
'paged' => $paged,
'meta_query' => array(
array(
'key' => 'votes_percent',
'value' => '50',
'compare' => '>',
'type' => 'numeric',
)
)
);
$s_query = http_build_query($s_array);
$is_query = '&' . $s_query;
$s_streaming = $query_string . $is_query;
query_posts($s_streaming);
Quando faccio eco a $ s_streaming ottengo
s=test&category=wordpress&post_type=blog&caller_get_posts=1&paged=1&meta_query%5B0%5D%5Bkey%5D=votes_percent&meta_query%5B0%5D%5Bvalue%5D=50&meta_query%5B0%5D%5Bcompare%5D=%3E&meta_query%5B0%5D%5Btype%5D=numeric
Se rimuovo le chiavi Meta_Query funziona, quindi immagino che sia dove risiede il mio problema.
Funziona bene così
query_posts($s_array); //just using the array to filter
query_posts($query_string); //just using the search query
//$query_string = 's=test&category=wordpress';
Sto cercando di costruire la stringa per query, perché questo fallisce.
query_posts($query_string . $s_array); //using both
Qualcuno può indicarmi nella giusta direzione?
Nessuna soluzione corretta
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange