• Mediatricks

    (@mediatricks)


    I am trying to call a list of all IMAGES stored as posts in the WP database. The array below will only show me uploaded jpgs.

    If I delete the post_mime_type line I get ALL attachments (but that includes icons, video mp3 etc.)

    I want to see only gif, jpg and png attachments returned but can’t seem to find any way to add a conditional element to the array.

    $args = array(
    ‘post_type’ => ‘attachment’,
    ‘numberposts’ => 20,
    ‘post_status’ => null,
    ‘post_parent’ => $page, // Post number
    ‘post_mime_type’ => ‘image/jpeg’, //Need to add an OR statement ???
    ‘order’ => ‘DESC’,
    );
    $attachments = get_posts($args);

    Please can someone help me!

Viewing 1 replies (of 1 total)
  • I also need to add a conditional statement to an array. I’m using this same code to put attachments on my home page. But I only want to pull attachments from specific categories.

Viewing 1 replies (of 1 total)

The topic ‘Adding and EITHER OR statement in an $args array’ is closed to new replies.