You don’t want ORDER BY $wpdb->postmeta.post_id rand(). If you had debugging enabled, you’d see an error. You need to separate ORDER BY values with a comma– ORDER BY $wpdb->postmeta.post_id, rand(). In your case, that won’t do any good because the first value gets precedence, so the query will order by the ID and then randomize “within” that first level order… but there is not “within” in this case.
Just use ORDER BY rand()
Related Posts:
- Adding ‘menu order’ column to custom post type admin screen
- Displaying a custom post type alphabetically
- Order by & include array by specific post ids
- Sort Order for a Custom Query in a Post Type Archive Not Working
- Select All in Parent Category, Group by Child Category?
- Get terms that contain posts that in turn belong to other terms?
- Ordering posts having multiple post-meta date fields
- Order Posts by Taxonomy and Meta Value
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- Custom Post type sort order not working in the admin area
- Order posts by (hierarchical custom) taxonomy terms and term children
- Compare 3 custom fields and sort by oldest
- ascending order custom post type
- query order by date on custom type: wrong order
- Taxonomy list. Order by a specific custom post type count
- Want to filter only parent post in admin area
- $wpdb returns no results with SELECT query on custom post type, works on default post type
- WooCommerce – Show orders for a specific product ? [closed]
- Inserting data into `post meta` table?
- Custom Post Type order by modified date and custom meta field issue
- How to best delete orphan wp_postmeta
- How to query different post types in specific order?
- Custom Post Type + 20k posts = blank/404 within Admin edit.php [duplicate]
- How do I make a custom taxonomy for a CPT appear inbetween title and editor boxes?
- Combining sorted and random CPT
- Show listings from Impress Listing plugin in random order using taxonomy and terms
- I did group my search results by post type, but how can i give each of them its own order?
- Ordering posts in Search & taxonomy by post_meta
- Insert post metadata for all posts in CPT at once if metadata no existent
- Rewrite and custom post type: order by custom field not working
- convert custom query to wp_query
- How to set order for a custom post type
- Previous/Next Link by Meta Value in CPT
- using $wpdb to get custom post type with term
- How to order separated Custom Post Search results
- Wp_query: sort by PHP variable
- Allow user to set custom order to a list of custom taxonomies?
- Converting the_content string to an array?
- Display custom fields from custom posts in RSS feed
- How to do WP_Query with two meta fields with orderby clause
- How to order and group custom post type posts by year and month
- Get terms that contain posts that in turn belong to other terms?
- Display Woocommerce Orders for specific author [closed]
- Ordering custom post type by multiple custom fields
- Order by custom field meta_key date and then by custom file meta_key number
- $post not working working in AJAX plugin with custom post type
- Archive not sorting correctly
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Ascending Order is not Working in Custom Post Type Listining
- Custom post type sorting: alphabetical order
- WPDB for post count on post
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- WP_Query not resetting after wp_reset_postdata
- Post ordering not working with custom field
- Adding Page Ordering to a Custom Page Type
- $wpdb is queried but results don’t show
- Displaying Portfolio Filter by Category Order (alphabetically)
- show most viewed posts of last days by link?
- Changing WordPress sort order for returned child pages
- Order posts by taxonomy terms
- See if the email exists or not
- wp rest api orderby field in a custom table
- Display Parent-Child Posts in specific order by comparing IDs in array
- How can I sort the results of a REST API response by the title of a connected custom post type?
- Does this archive template part look like its making too many calls to the db?
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- Filter in Custom post type to find the parent post
- How to order taxonomy terms by most recent post?
- Orderby if between two meta fields
- Display custom posts, ordered by most commented, without duplicates
- SEARCH QUERIES – REVERSE OUTPUT
- order custom post type posts by custom date
- How to order multiple custom post types with same taxonomy by date
- Wp Query sort order from custom MetaBox
- How to store additional data that is related to core data
- Using Orderby and meta_value to order natural/alphanumerical
- Update 2 wordpress tables at once
- How to use costum database table for custom post type
- What’s the most efficient way to get two queries based on an if statement?
- WP Query with multiple post types ordered by custom meta date then published date
- Orderby modified only for specific post types
- Custom post order when using OR relation
- Custom Post save causes 500 error
- shortcode order for event custom post type
- Order Custom Posts by Several Fields
- Query Distinct Taxonomies of Custom Post Type
- show previous/next post orderer by title in custom post types
- Adapting plugin for custom post type?
- Retrieve post data via WPDB class
- $wpdb returns no results with SELECT query on custom post type, works on default post type
- 404 on Pages for Custom Post Type & Query_Posts
- Allow admin to determine the order of queries?
- Trying to display posts by authors in with specific user meta
- Order custom post type is beign ignored
- How to order different custom post type in category or tag template page?
- WP_query orderby not working after WP4.0 update [closed]
- Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]
- Query order by meta value force specific tag first
- Order Wp Query by earliest of 3 dates meta query
- Query multiple post types – Order by type and post title title