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
- How to show only specific tag in wordpress loop
- How to get current page id and compare it to looped pages inside the same page?
- Img alt tag showing different value then entered
- Show amount of posts created today above loop?
- How to create WordPress loop with combination of 4 and 2 columns twitter-bootstrap?
- Add Image field to CPT
- How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?
- How to implement template file and the loop
- Featured Image not changing
- WooCommerce custom loop pagination on front page
- Show only posts from todays date [duplicate]
- Eliminate duplicates in a foreach loop [closed]
- Getting post id in for loop
- Single Loop With Dual Content Area
- Tag custom loop show posts
- Add image custom attribute [closed]
- While loop inside another while loop
- I need to update the post query? [closed]
- Different style for first two (sticky) posts
- Loop display only 5 posts
- Wrap every 2 divs in row – for each loop [closed]
- How to use add_action(“wpcf7_before_send_mail” outside wp loop?
- Custom Post Type archive above Single Post in single.php (same author)
- WooCommerce – Checkout suddenly stops working [closed]
- How to add class to the last image of the last post in a loop
- Posts Loops To Display Specific Posts Inside Page Template?
- posts_nav_link() not working on index.php
- HTML in PHP problem [closed]
- Applying a filter to multiple loops for days ago
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- Use callback function in AJAX pure javascript [closed]
- How to add custom HTML markup and classes to the_content()?
- Problem with ms-thumb-frame-selected class in Master Slider
- pull 500 post of many from database [duplicate]
- WordPress loop put title into variable
- I want the first post on my home page to be lengthier than the rest (example included)
- $do_not_duplicate is not working in genesis theme
- Loop with Custom Post Type Taxonomies and Interstitial Code
- How do I display 3 post each in a bootstrap carousel?
- Question about custom plugin
- Loop displays current page
- Edit image alignment in WordPress twentysixteen child theme on attachment page [closed]
- Multiple loops using next_posts_link & previous_posts_link
- ACF loops false value with repeater and checkbox
- How to do query_posts on tags pages
- loop mix my child-category and parent-category
- Display Featured Image
- Showing ads after posts in home page
- AJAX in wordpress theme loop
- Duplicate post problem
- repeating posts on 2nd page to posts
- the_content() “crashes” for single pages
- How to toggle a div element between two images when click two submit buttons in a wordpress loop?
- Best hook for a function which adds shortcodes to the system?
- Same posts within a paginated page
- Multiple loop with pagination in same page
- Fix html inside a for loop [closed]
- Adding vkontakte social “like” button to posts results in multiple buttons on first post only
- Error in Wordprewss loop for page template [closed]
- Want to images load first then title in WordPress loop
- Tags outside the loop
- Display all posts in a page code for template
- How to add a continuous number to HTML tag attribute value inside The Loop [closed]
- Undefined variable: woocommerce_loop [closed]
- Loop that displays all posts by logged in user, with Post Edit link
- WordPress Not Sorting By Custom Field