There’s nothing WordPress-specific about this, just some simple php:
// generate an array of numbers
$numbers = range( 1, 8 );
// shuffle the array in random order
shuffle( $numbers );
// use the first 4 values from the randomized array of numbers
echo eh_get_option( 'eh_slide_image_' . $numbers[0] );
echo eh_get_option( 'eh_slide_image_' . $numbers[1] );
echo eh_get_option( 'eh_slide_image_' . $numbers[2] );
echo eh_get_option( 'eh_slide_image_' . $numbers[3] );
If you have a lot of markup to repeat, you can output things in a loop:
$numbers = range( 1, 8 );
shuffle( $numbers );
for ( $i = 0; $i < 4; $i++ ) {
echo eh_get_option( 'eh_slide_image_' . $numbers[$i] );
}
Related Posts:
- This CSS Stuffing Works, But Is This A Good Practice?
- Settings API – easiest way of validating checkboxes?
- WordPress Admin back-end – advanced options page?
- How To View Site from Non-Logged-In User’s Perspective
- wp_dropdown_pages() in theme admin page
- How can I show the contents of only a few users
- Settings API not saving values to database
- Admin option sidebar count
- Problem with Settings API: changes are not saved after submit
- Add Custom Script in Other Plugin’s Options page
- Accessing variable from admin panel?
- How can I POST or GET to the same admin page from which I am POST-ing or GET-ing
- WordPress custom admin functions security
- Show global Message in User Profiles with admin only Input field in WordPress Backend
- [Multisite]How can I update custom blog option?
- Call require_once form admin page with checkbox
- Get Link of Page Selected through a Select Field in Custom Admin Page
- My code for creating an admin option doesn’t work
- I don’t have permission to save the theme options I created myself?
- Woo Commerce Settings for Check-out Form [closed]
- What are the standard admin CSS id/class tags?
- how to know if admin is in edit page or post [duplicate]
- How to remove entire admin menu?
- The website cannot display the page
- Set Default Admin Colour For All Users
- How can I target WordPress 3.8 new interface MP6 with CSS?
- How do I create my own admin button and theme settings page?
- initial sort order for a sortable custom column in admin
- Uploading files in admin panel?
- Redirect Admin User in Dashboard
- Read only capability for custom post in admin area
- How can ‘admin_email’ be set?
- Remove ability to access certain admin menus
- Gutenberg “Add Block” button is not active (greyed out), cannot add new blocks
- Conditional check for front-end which includes ajax
- Hide update messages from non-admin users?
- Daily notices of failed login attempts for non-existent admin user
- Reorder plugin items in the admin menu
- Reference external file as a function
- “Automatically add new top-level pages” Default
- Is it possible to hook AJAX to UPDATE-button?
- Get email address of type Administrator
- Check if user is logged in else login page
- Which hook for processing plugin page form data?
- Calling a shortcode in the backend
- Is there a way to have admins that are logged in to wordpress not have to enter the password for password protected pages while browsing the website?
- Error thrown. Cannot create references to/from string offsets
- How to receive security update notification email?
- Include admins in author drop-down on edit post screen
- How to restrict wp-admin and prevent upload errors
- Adding another “Add Post” button to admin
- Admin page redirect to another admin page
- How to determine if an admin is logged in outside the loop
- What determines whether admin toolbar is shown to a logged-in user?
- Adding text in more than one language (at the same time)
- How to get view count of every page on site and add that (increasing) number to Dashboard Widget
- Restrict function call to page load but not ajax call
- How can I display/hide certain content based on a Theme Option field?
- How do I remove All and Published if not admin?
- How to disable https from wordpress site?
- Fatal error: Exception thrown without a stack frame in Unknown on line 0
- Where should I hook into admin?
- Dashboard menu missing
- How to remove wp panel for users
- Unable to upload image using the standard uploader in the WP admin (v4.3)
- Admin role not really admin
- Featured image on post edit page not loading over HTTPS
- Copying WordPress site, HOW about the DB connection?
- How do I diagnose a plugin resource 404?
- Post editor is 89953px tall. How to fix?
- Does an administrator access allow someone to access to the WordPress database?
- Change Name of Category Heading in New Post
- How to make sure your admin doesn’t hi-jack you site?
- Admin bar is disabled in front
- Disable login on multisite web sites
- Other than save_post any other actions on add / edit post screen?
- Add JavaScript in admin in custom plugin [duplicate]
- Remove iPhone detection on login page
- Dashboard RSS Widget Overhaul
- Possible to show in media library if images are being used as featured images?
- How can all E-mails be sent with BCC copy to Admin?
- How To Create WordPress Dashboard Item
- Login to admin by frontend form?
- Doesn’t call user information to include “wp-load.php” in an external php file
- How do I add an admin table to my page?
- How to save edited post when submitting form
- Show admin bar to editors with Buddypres
- Redirect non-admin after login, and in url – /admin
- Admin hook after editing an image?
- Form submit in admin does not set is_admin() true
- Get the selected posts IDs to use in bulk edit AJAX call
- Disabling “View” mentions from backend?
- User interfaces living in the Admin “back end” area
- Capability to read/edit page in wp-admin only for administrators
- blank white page in admin, white space hunting?
- WordPress blog code format
- htaccess and htpasswd
- Exclude admin from the top commenters list [duplicate]
- Troubleshooting white screen when editing specific posts
- You do not have permission to access this document on form submit