• I found a ‘resolved’ topic here which was very helpful in returning the latest attachment to a post. I want to do a similar thing and retrieve an array of all the attachments to a post.

    The code on the very helpful topic i found is this:

    <?php
    global $wpdb;
    $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1");
    ?>

    Followed by several options to then display the properties of that attachment:
    <?php the_attachment_link($attachment_id); ?>
    <?php echo get_attachment_icon($attachment_id); ?>

    What i would like to do is exactly the same but i want to pull a list or array of all attachments to the post then display these attachments as above.

    Any help is appreciated, Thanks.

Viewing 1 replies (of 1 total)
  • LIMIT 1

    Limits to one (1) element.
    Remove it show all, or another number to show up to that amount.

Viewing 1 replies (of 1 total)
  • The topic ‘Return an array of attachments to post’ is closed to new replies.