• User Attivo

    Mostrare ultimi attachment di wordpress

    Ciao ragazzi.

    Utilizzo il seguente codice per mostrare gli ultimi allegati degli articoli in wordpress:

    <?php
    $args = array(
     'post_type' => 'attachment',
     'numberposts' => 20,
     'post_status' => null,
     'post_parent' => null, // any parent
     ); 
    $attachments = get_posts($args);
    if ($attachments) {
     foreach ($attachments as $post) {
      setup_postdata($post);
      the_attachment_link($post->ID, false, '', true);
      
     }
    }
    ?>
    

    Uso quindi la funzione the_attachment_link di Wordpress. Mi chiedevo se era possibile filtrare quest lista che viene mostrata in modo da elencare solo gli allegato contenuti in articoli pubblicati e non gli allegati presenti in articoli in bozza o in programmazione.

    E' possibile?

    Grazie mille per l'attenzione