Tengo una galería adjunta a una página. En esa página, estoy ejecutando la siguiente consulta:
$events_gallery = new WP_Query( // Start a new query for our videos
array(
'post_parent' => $post->ID, // Get data from the current post
'post_type' => 'attachment', // Only bring back attachments
'post_mime_type' => 'image', // Only bring back attachments that are images
'posts_per_page' => '3', // Show us the first three results
'status' => 'inherit', // Inherit the status of the parent post
'orderby' => 'rand', // Order the attachments randomly
)
);
He experimentado varias formas y, por alguna razón, no puedo devolver los archivos adjuntos. ¿Me estoy perdiendo algo obvio aquí?
Actualizar*
Gracias a Wok por señalarme en la dirección correcta.
Resulta que estaba usando "status" en lugar de "post_status". El códice había usado "estado" como ejemplo en su explicación en contexto del tipo de publicación "adjunto". Actualicé el códice para hacer referencia a "post_status" en su lugar. El código correcto es el siguiente:
$events_gallery = new WP_Query( // Start a new query for our videos
array(
'post_parent' => $post->ID, // Get data from the current post
'post_type' => 'attachment', // Only bring back attachments
'post_mime_type' => 'image', // Only bring back attachments that are images
'posts_per_page' => '3', // Show us the first result
'post_status' => 'inherit', // Attachments default to "inherit", rather than published. Use "inherit" or "all".
'orderby' => 'rand', // Order the attachments randomly
)
);