Looking for any pointers really.
The functionality I’m after
Basically I’d like to have the functionality to assign up to 6 different images to one single post. All 6 images will be displayed as normal within single.php. On the homepage, for example, I’d then like one of those images to be randomly displayed on page load for that post.
A couple of questions
- Is this even possible?
- Is there a plugin that can manage this sort of thing?
- If I were to do it myself how should I go about creating this sort of functionality?
Yes it is possible, and not all that difficult. You upload the images when creating the post.
Then in single.php you use get_children to get all images from the post.
assuming in the loop:
and output them like so:
For your random image you could either use the same get_children as above but add
&numberposts=1to the args string.or something like:
This will give you only one random image, and it will be random, whereas get_children will pull out the same image each time unless you add order and orderby arguments, which will allow you to change which image comes out.
To echo the image within a div just call the function: