Site icon Hip-Hop Website Design and Development

Damaged? WP_Query and "attachment" as a publish sort

I’ve a gallery hooked up to a web page. On that web page, I am working the next question:

$events_gallery = new WP_Query( // Begin a brand new question for our movies
array(
    'post_parent' => $post->ID, // Get knowledge from the present publish
    'post_type' => 'attachment', // Solely convey again attachments
    'post_mime_type' => 'picture', // Solely convey again attachments which might be photographs
    'posts_per_page' => '3', // Present us the primary three outcomes
    'standing' => 'inherit', // Inherit the standing of the guardian publish 
    'orderby' => 'rand', // Order the attachments randomly  
    )
);

I’ve experimented fairly just a few methods and, for some motive, I can not get attachments to return. Am I lacking one thing apparent right here?

Replace*

Due to Wok for pointing me in the precise route.

It seems I used to be utilizing “standing” as an alternative of “post_status”. The codex had used “standing” as the instance in its in-context rationalization of the “attachment” publish sort. I up to date the codex to reference “post_status” as an alternative. The proper code is as follows:

$events_gallery = new WP_Query( // Begin a brand new question for our movies
array(
    'post_parent' => $post->ID, // Get knowledge from the present publish
    'post_type' => 'attachment', // Solely convey again attachments
    'post_mime_type' => 'picture', // Solely convey again attachments which might be photographs
    'posts_per_page' => '3', // Present us the primary three outcomes
    'post_status' => 'inherit', // Attachments default to "inherit", quite than revealed. Use "inherit" or "any".
    'orderby' => 'rand', // Order the attachments randomly  
    )
);