• First, this thread-pull latest attachment… was very helpful — so close

    Rather than cycle through an entire collection of posts for a given category, how would I grab the first post in the category with an image attachment?

    Something along the lines of:

    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");

  • The topic ‘Pull last posted image from posts in category (outside loop)’ is closed to new replies.