WP Query per ottenere tutti i post (inclusi bozze/in attesa di revisione)

28 feb 2012, 00:38:14
Visualizzazioni: 27.1K
Voti: 4

Attualmente ho la seguente query:

$args = array(
              'post_type' => 'post',
              'orderby'   => 'title',
              'order'     => 'ASC',
              'posts_per_page' => 10,
            );

$my_query = new WP_Query($args);

while ($my_query->have_posts()) : $my_query->the_post(); ?>

Questa query restituisce tutti i post che sono pubblicati. Come posso modificarla per mostrare ogni post, sia esso pubblicato, in attesa di approvazione o in bozza?

0
Tutte le risposte alla domanda 2
0
12

Puoi aggiungere post_status alla tua query, la stringa 'any' restituirà tutti i post indipendentemente dallo stato, oppure puoi utilizzare un array per recuperare solo quelli che desideri.

$args = array(
              'post_type' => 'post',
              'orderby'   => 'title',
              'order'     => 'ASC',
              'post_status' => 'any',
              'posts_per_page' => 10,
            );

http://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters

28 feb 2012 01:17:32
0

Puoi anche personalizzare per articoli in attesa, bozze o qualsiasi stato selezionato

$args = array(
              'post_type' => 'post',
              'orderby'   => 'title',
              'order'     => 'ASC',
              'post_status' => array( 'pending', 'draft', 'future' ),
              'posts_per_page' => 10,
            );
28 ago 2015 01:36:46