Background:
I'm trying to display images in a slideshow, and I want to select those pictures randomly from the website's media. The image has a custom field in order to be selected for being the slideshow.
I was able to figure all of that out, and I used a wp_query to find all of the images with the custom field that says it could be used in the slideshow.
Question:
Now my problem is how should I go about looping through the query to get to the post number I want?
Code:
$args = array(
'post_type' => 'attachment',
'meta_key' => 'on_front_page',
'meta_value' => '1'
);
$wp_query = new WP_Query($args);
$total_images = (int) $wp_query->found_posts;
if ($total_image >= 6) {
for ($i = 0; $i < 6; $i++) {
rand(0, $total_images);
}
}
elseif ($total_image >= 6) {
for ($i = 0; $i < $total_image; $i++) {
rand(0, $total_images);
}
}