• I’m using :

    <?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 menu_order DESC LIMIT 1");
    ?>
    
    <?php echo wp_get_attachment_url( $attachment_id ); ?>

    to pull out the first image attached to a post. Is there a way for me to pull out a specific image based on it’s order besides just the first and last? Is there a way for me to pick the 2nd or 3rd image for instance?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to pull image urls based on menu order in a post?’ is closed to new replies.