2012-10-17 9 views
23

Ho questa query che restituisce solo alcune delle voci che ho sulla tabella. Ho più di 10 messaggi, ma questa query restituisce solo 6. Si prega di aiutare con suggerimentiWP_Query() non restituisce tutte le voci

$query = new WP_Query("year=2011&monthnum=09&post_status=publish&post_type=post&orderby=post_date&order=DESC"); 
while ($query->have_posts()): 
    $query->the_post(); 
    $title=get_the_Title();                             
    echo"<p><input type=\"checkbox\" name=\"MyArticle[]\" value=\"".get_the_ID()."\">".get_the_Title()."</p>"; 
endwhile;    
wp_reset_query(); 
+1

' "L'anno = 2011 & monthnum = 09 & post_status = pubblicare & post_type = post & orderby = POST_DATE & order = DESC"' è la forza trainante nella classe 'WP_Query'. La mia ipotesi sarebbe che 4 dei post non abbiano un anno, un mese o uno stato di pubblicazione corretto. – Xhynk

risposta

78

Prova ad aggiungere posts_per_page=-1 alla stringa di parametri passati a WP_Query.

Se il valore non è impostato, torna a utilizzare l'opzione di post predefinita per pagina impostata su Settings >> Reading >> Blog pages show at most.

La mia ipotesi è che questo valore è 6 quindi restituisce così tanti post poiché non è stato specificato un limite diverso.

+2

** posts_per_page = -1 ** risolto il problema. Grazie mille –

+7

Questa sarebbe la risposta corretta, a prescindere dal fatto che abbiate risposto o meno. Grazie –

+1

Questo risolve il problema della Query che non restituisce nulla. Questo succede quando i post raggiungono una certa età. Questo li riporta tutti indietro! – korylprince

9
$args = array(
    'post_type' => 'product', 
    'orderby' => 'ASC', 
    'posts_per_page'=>-1 
); 
$wp_query = new WP_Query($args); 
Problemi correlati