imágenes cargados se almacenan como mensajes con el tipo de "unión"; use get_posts() con los parámetros correctos. En the Codex entry for get_posts(), este ejemplo:
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null, // any parent
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $post) {
setup_postdata($post);
the_title();
the_attachment_link($post->ID, false);
the_excerpt();
}
}
?>
... recorre todos los archivos adjuntos y los muestra.
Si solo desea obtener imágenes, como comentó TheDeadMedic, puede filtrar con 'post_mime_type' => 'image'
en los argumentos.
Sí, sólo puede usar '=> 'image'' 'post_mime_type' en su' $ args', y WordPress va a coincidir inteligentemente que contra todos los tipos MIME imagen :) – TheDeadMedic
@TheDeadMedic bueno saber! Nunca he necesitado recuperar tipos particulares. –
¡Buena respuesta y felicitaciones a TheDeadMedic por hacer coincidir los tipos de mimo! :) – hsatterwhite