My solution was really simple:
$input = array("defaultImage1.jpeg", "defaultImage2.jpeg", "defaultImage3.jpeg", "defaultImage4.jpeg", "defaultImage5.jpeg", "defaultImage6.jpeg");
$rand_keys = array_rand($input, 2);
echo '<img class="story-carousel" src="'.$upload_dir['url']."https://wordpress.stackexchange.com/".$input[$rand_keys[0]].'" alt="">';
Related Posts:
- Change the way wordpress outputs images or image galleries
- Loop.php vs looping inside template file
- How do I prevent one of two multiple loops from repeating on a second page?
- Show newly added posts since last user login time /date
- How do I override part of the main loop in my child theme?
- Customize WooCommerce Product Images (Placement and size) [closed]
- Recent posts on a static home page
- Page-loop is looping content from custom loops on the same site. How to avoid that?
- Split wordpress loop to multiple layouts
- How do I automate multiple category loops?
- Closing the loop…featured image variable based on post id
- using wp_get_attachment_image_src in foreach loop
- How to print redux gallery feilds id? [closed]
- get_delete_post_link() inside Loop stubbornly returns nothing
- Integrating WordPress with Your Website
- Multiple instances of Featured Image Thumbnail As A Background On Homepage
- Pagination for two loops
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Get gallery in loop through ajax
- Get a specific size from wp_get_attachment_image_src
- Return only one post format in index.php [duplicate]
- Cant pull in featured Image
- How do I aproach this?(for sale, for lease, sold->move something from a category to another)
- Display single post inside accordion based on form submission results
- Get gallery and product gallery images full size
- Building theme so user can change header image [closed]
- Is there a way to target only images within the loop?
- trying to write a variable into a wp_query, need help!
- display only parent replies count in index.php
- Displaying posts limit: can’t get pagination to display [duplicate]
- Loop doesn’t give the thumbnail the right parent (or class)
- How wp maps urls into files
- Custom Page Template and Category Exclusion
- Limitless amount of posts in custom archive page
- Using the Loop to show all levels of subpages under a parent page? Halfway there
- Cleanest Way to Select Every Second Element in a Loop?
- Get post by page name or slug
- Creating a rotating header /image slider using theme customization
- Why do themes have `while( have_posts() )` in templates like single.php?
- What is best way passing variables to theme templates and using them different places like widgets?
- Apply styling only to first page sticky posts
- Broken pagination
- Loop through child images of a parent for a Nivo Slider
- Too many nested wp_query loops in this hypothetical query?
- pop-up lighbox with AJAX
- Change loop order via form or link (jquery, not URL)
- Limit author image size
- WordPress Loop – Style rows of posts differently
- Add filename to attachment page url
- Show post page only if the user has bought a specific product
- taxonomy tags 404 to custom post types
- Adding width and height to wp_get_attachment_image_src
- Only display videos and images in the_content() within loop
- Query last updated posts (posts updated in the last 24 hours)
- Publish Categories for a particular Author on a given Post
- Why does `inclusive` not work in this wordpress loop?
- Displaying page image in the footer automatically
- Loop inside query
- How can I display other user avatars on an author profile page?
- something strange is happening to my code
- How to modify search.php to not show pages only show posts
- Show image if author meta (profile fields) exists outside loop
- Show articles in Pair
- Loop in elementor custom widget not working
- Randomly display post based on meta value. (Kind of Priority/Weight)
- Make a loop to return x number of posts, but only if they have content or excerpt
- How do you stop the rendering of the website to have something display on the front-end?
- add_action in the loop hooks
- toggle Multiple Loop with tittle
- How to render the single post template with the post name?
- new custom theme – posts displaying on top of one another
- Offset Loop by 1 , Limit next loop to 1 (Most Recent) Post
- Building a form with WordPress, and also pulling that data for a user page
- Database query and get_user_meta return incorrect data
- Why my loop is repeat?
- Excerpts not showing on main page
- dispaly all hierarchical post types from a taxonomy
- Alt attribute is not showing while the value is given in Media
- WordPress Modal showing posts not working properly
- Is it possible to get a post ID of a 2 different custom post types loop embedded in the same post to perform update_post_meta from the frontend?
- Loop shows post 5 times in a query
- How to keep a CPT stick to specific position?
- Attachment Metadata inside of Loop
- Make custom WordPress comments list
- Change default “Apply Changes To” radio option when editing images
- Template included with plugin doesn’t return all posts for custom taxonomy
- Default Template infinite loop of Title
- Adding pagination to WP_Query [duplicate]
- Insert/sticky multiple posts in multiple positions
- Stuck with conflicting loops on page template
- How can I access ‘key’ and ‘value’ from an array in a for loop?
- How to get current page id and compare it to looped pages inside the same page?
- Show amount of posts created today above loop?
- How to create WordPress loop with combination of 4 and 2 columns twitter-bootstrap?
- posts_nav_link() not working on index.php
- HTML in PHP problem [closed]
- How to add custom HTML markup and classes to the_content()?
- Tags outside the loop
- wp_mail sending only once inside foreach loop
- How to use orderby on meta_value when using Pods custom database table storage