WP_Query
has an orderby
property which can be set to rand
. If you change your query string to 'post_type=announcements&posts_per_page=5&orderby=rand'
you should be good to go. You might want to take the time to read through the whole documentation for WP_Query
, just so you’re familiar with its capabilities.
Related Posts:
- Replacing the title in admin list table
- Replacing the title in admin list table
- the_title filter returning wrong post type
- Custom post type title is set by other custom post type
- Display post content with respect to its title?
- Limit the Title Length on Custom Post Type Archive Page to a Set Number of Characters
- the_title not working
- Can’t Get Parent and Child Categories of Custom Taxonomy to Display
- Is it possible to create 2 unique titles for an Events custom post type: Upcoming Events and Past Events?
- Display title of custom post type dynamically
- Custom Post Type title not populating
- Remove space when post title is blank
- How do test if a post is a custom post type?
- WordPress dashboard, viewing CPT results in 504
- Merge two custom post types into one admin page?
- Remove the “View” Link in Post Admin
- Displaying category archive of custom post types
- Define permalinks for custom post type by taxonomy in WP 3.4
- How to change the quantity of feeds in custom post type?
- update a post meta from a single table cell TablePress
- Custom post type Vs. data in own table
- Customize Search to only search current custom post type
- Jetpack infinite scroll render – make different depending on post type?
- Custom Post type taxonomy single templates
- List custom post type but redirects to home page
- How to search CPT’s by meta query from the admin dashboard?
- Displaying custom posts only if custom meta box’s date is not expired
- How to get category image custom post type taxonomy in wordpress?
- Integrating Orbit slider into wordpress through custom post type
- how to get archive urls with same origin for custom types and terms?
- Custom Query to display posts with custom field
- Export entries and multiple custom field meta to .csv?
- advanced search forms with 3 input text and that the main problem 3 input text
- Is possible to add post-formats to custom-post-type?
- Editable Meta Data for Custom Post Type Archive Template
- Filter by custom taxonomy slug on a custom post type
- Create 3 Level Relations with ACF and WordPress
- Why does wordpress keep adding postname to my CPT’s permalink in the end?
- Archive page for taxonomy terms
- Keep display metadata value on backend – Custom Metabox
- Custom Post Type Set Comments ON by default without show METABOX
- Notify admin on new submit
- Limit amount of posts made within a custom taxonomy
- Adding custom post types to archive
- Anon function and add_meta_box
- Custom post type – use ajax to display sub pages
- Custom post type and taxonomy permalinks
- re-register custom post type with custom capabilities
- Query based on custom fields start and end date
- Create a permalink structure with custom taxonomies and custom post types gives 404
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- How to change “post_class()” for a custom post type?
- Custom post type menu-icon not showing up
- Using page slug in wp_query
- Assign post type to many users
- Meta box values not displaying in Post Edit Screen after save
- Separate Content from gallery (custom post type)
- Problems with custom post type
- Custom Ratings for Theme, Proper way to Refactor Code and Clean up Template File
- url rewriting for custom post types
- Display list of custom post type which match taxonomy
- Sort results without WP_QUERY?
- What happens to my older posts if I switch to a child theme?
- Update custom field value
- Query Custom Post by taxonomy multiple categories
- Create a Custom Path to Archive
- show most viewed posts of last days by link?
- Advanced archive url structure (category, tag and date)
- Trying to create a custom post type, post type box doesn’t show up?
- Front End Dropdown Showing All Custom Post Type ‘Agent’
- Checking for custom field in admin pages
- Create if else for post types in WP_Query ‘post__in’ values
- Can’t Export Custom Post Types With Export Tool In A Custom Theme
- DIVI Theme customizer changes not applied on existing pages and designs are not shown on the front
- How to create a product details slider on post?
- I’m trying to create an if statement that will only display my button link for tickets if its under ‘admission-event’… what is wrong with my code?
- Attend event form with ajax
- Populating Custom Fields from live JSON
- How to add custom PHP code in post header?
- How to enable post types on Page Attributes?
- Change custom post type permalink according to category
- pre_get_posts gives 404 error on Custom Post
- Custom Post Type conditional statement for ID of single post
- WordPress loop multiple orderby query with Types toolset
- In WordPress do I create tables for my plugin or do I create custom post types for a Student and Classes Registration system?
- Create Custom Post Type PDF File (Like Media) Then Add Searchable Custom Fields
- Related posts by taxonomy [duplicate]
- Repeatable WordPress custom fields in a metabox
- remove custom post type ulr
- Multiple Queries and Loops within CPT Archive
- Displaying information from Custom Fields in template with Types?
- Create shortcode for list of custom post titles with custom fields alongside
- Add text to metabox input text field from Thickbox
- Get custom post fields and display them
- PHP Button Custom link [closed]
- Automatically add custom taxonomy when meta value gets to a set number or beyond
- Custom post type, when type non existing post name, it query the nearest possible post name by default. How can I disabled this behavior
- How can I show template dropdown in custom post type?
- How to dynamically register custom post type
- Pagination not working only on Archive-Name.php using new WP_Query