This line is responsible for posts that are showing:
query_posts('showposts=4');
All you tell in it is “take 4 posts” and WP will take 4 most recent posts, because that’s the default behavior.
If you want to take random posts, you have to tell WP to order posts randomly:
query_posts( array(
'posts_per_page' => 4,
'orderby' => 'rand'
) );
Related Posts:
- How to fix ‘Notice: Undefined index:’ in PHP form action
- Pass a PHP variable to another file
- Fatal error: Call to undefined function plugin_dir_path()
- Switching wp_get_sites to get_sites
- How to get author ID when an author page is being viewed?
- Modify image while uploading
- Using Global Variables Expensive for PHP
- One button to change all settings in theme customizer?
- How to remove html comment from source?
- Add custom image sizes to media uploader
- Export all post from database to JSON only when the database gets updated
- How php content after the first and second paragraph
- Multiple pages on one with different HTML
- How to resolve error “Cookies are blocked due to unexpected output.”?
- Can’t use get_results() in ajax query
- Is $hook a global variable in WordPress
- Notice: wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- Convert imploded plain text into links
- WordPress get pagination on wpdb get_results
- PHP if Condition not working
- Sorting Posts | Alphabetical Order
- How to return a foreach inside a shortcode
- Extend a class of a plugin
- Include a php file from functions.php only to homepage
- How to get the Page Number of the Current Page in Single Post Pagination
- Handling Body class based on Template
- Storing Array from returned database query and using the array in a new query
- Changing layout with wp_customise
- Mass update excerpt
- Show prices with tax in Woocommerce Mini Cart [closed]
- WordPress ajax doesn’t display object method on jQuery .change() function
- Get post id in a function when edit/add a post
- Reconfiguring WordPress site
- Use Icomoon external svg file with
- get_template_part based upon post’s category
- How to split links generated into an xml sitemap to avoid exceeding 30 sec maximum execution time?
- Hacked WordPress website /Homepage redirect [closed]
- Query if audio attachment AND/OR custom field
- Database query works fine outside WordPress
- WordPress page content outside WordPress
- How to solve Woocommerce Memory Limit
- Shortcode to find and replace URL
- How to add drag and drop functionalities to a div inside option panel
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Seo Friendly Filter URLs
- PHP contact form not redirecting [closed]
- entire JS folder not loading in a WP theme
- Add new post in existing categories using wp_insert_post
- I’m unable to call img path using single quotes in an array?
- Else/If Statement to Display Photo Descriptions
- PHP error with a shortcode: “no suitable wrapper” for file_get_contents
- Correct code to use php in text widget
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- custom header text
- Display additional page templates and a sidebar on plugin activation
- Dynamic menu with custom post types
- Too many errors on log
- I am trying to edit the homepage of the Shopper. Since published I can not make changes and wanted to see if i can disable in (tpl-page-homepage.php)
- I need to display posts in subcategory beside posts in main category
- Trying to copy linux blog locally with XAMPP – php fatal error
- unsetting actions (edit and trash) of specific posts from that list of all pages or posts based on each posts metabox value
- Add a Metabox checkbox to the Page Edit screen of wp-admin , which only certain roles can see and Makes only certain roles able to Edit said page
- Why is the current page loaded in the pop-up window and not the specified one?
- Display Results of SQL Query on WP site
- How to search order using database frontend short code WordPress
- Internal Server Errors – Moving working multi-site install to my localhost
- How to display MySQL table data which is stored as an array?
- Categories does not show Block editor WordPress
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- WordPress Slick Slider + Magnific Popup
- Fix common misspellings/errors based on array of replacements
- Search for single post by 2 tags
- Import Instagram post as WordPress post
- Redirect user role to a specific page on login in a multisite network?
- spl_autoload_register is slow for WordPress sites
- Contactform7: display results from CURL
- How to update option field in database on clicking the publish button in customizer
- Get current_post in reverse order with pagination
- Add ID to output only for first option
- A javascript function that simply runs a php function on the plugin
- get_post_thumbnail_id returns a negative number
- Escaping html for meta description
- How to make 2 similar functions more efficient
- how use php query in AJAX jquery
- Post from front end form to post_meta
- Echo the featured image of page assigned to blog in index.php
- Functions are causing errors
- Select All not working in a WordPress search filter
- Can’t remove menu items added by plugin
- Custom Meta Box If Else Statement
- Static pages not being allowed
- How to set if meta_value is lower < than other meta_value in a get_posts array?
- How to insert a variable into a query parameter?
- How to edit homepage in WordPress?
- ‘This Field is Required.’ is Not Displaying on CF7 [closed]
- REST API custom endpoints for metaboxes
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only
- generate excerpt from the part of big text dump that contains keyword
- How to sort search result by post_title, then by post_content
- Custom Admin Menu Report for Specific User ID