Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Random order of WP_Query results with highest meta value

OK, so you’re almost there. Let’s say you have this query:

$argsLoop = array(
    'post_type'      => 'cars',
    'posts_per_page' => 12,
    'paged'          => 1,
    'meta_key' => 'cars_price', 
    'orderby' => 'cars_price',
    'order' => 'DESC'
);
$cars = new WP_Query( $argsLoop );
// All you have to add is this line:
shuffle( $cars->posts );

Now you can do standard loop and the selected cars will be showed in random order.

Related Posts:

  1. Use WP_Query in shortcode
  2. Get Current User Id Inside a Loop Returns 0 For a Shortcode
  3. Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
  4. Is it possible to retrieve all posts with a certain value for metadata?
  5. Order a WP_Query by meta value where the value is an array
  6. Delete post meta by serialized meta value
  7. Efficient way of querying for a “fallback” post?
  8. wp_query with cat not working
  9. How to use an associative array in post__in with WP_Query?
  10. If Query In Sidebar
  11. Recent Posts slider, using WP_Query(), loads duplicate sliders
  12. Compare post-IDs within WP_Query? (Less than / Greater than)
  13. How to use $query->set with post__in?
  14. Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
  15. Sort custom meta column by other meta value
  16. Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
  17. Loading the same WP_Query in two different wordpress .php templates
  18. How to prevent WP_Query function from returning all posts when empty?
  19. How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
  20. Dynamic content based on a URL parameter
  21. Display a specific category of products in shop page and disable code for specific actions
  22. Creating user status mode in WordPress
  23. WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
  24. Need help with Google drive API [closed]
  25. Add more button if more 8 items
  26. How to store post ID’s in cookie or session to display the same posts later
  27. WordPress, AJAX and pre_get_posts using conditional tags
  28. Get users that likes the post
  29. get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
  30. Exclude posts based on meta value
  31. Recent Posts Not Showing Only On A Specific Category Page [closed]
  32. Custom query, checking values of multiple meta keys
  33. Archive post by meta value + 24hours
  34. auto-populating custom nav with all items from custom post type
  35. inserting a post from an extern php file but post content doesn’t show on wp site
  36. WordPress update_post_meta updating with empty meta_value field [closed]
  37. Remove echo from shortcode
  38. How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
  39. WordPress theme options error
  40. Security for data obtained from the database
  41. Fatal error: Call to a member function query() on a non-object
  42. Get posts from multiple post type
  43. Get post id within comments loop
  44. How to get all author posts outside of author templates
  45. WP_Query fails despite having 1 post
  46. Create a Blog Template Page
  47. Non-Closing PHP Query in WordPress Loop
  48. unable to use ‘new WP_Query’ in AJAX call
  49. wp_query get the 2nd post
  50. Exclude posts with specific metadata from search?
  51. How to get post ID in a Page?
  52. Display an image if odd number of posts in grid
  53. How to retrieve the data from the sever and displaying it in a page?
  54. Querying Database with wpdb
  55. How to add div blocks after certain set of post
  56. How to overwrite orderby with add_query_var
  57. update_post_meta only updating on last loop of foreach
  58. Why doesn’t PhotoSmash plugin play well with wp_query?
  59. how to get serialized post meta
  60. get_the_ID() in the footer returns wrong value
  61. Trouble inputting variable into WP query
  62. the_posts_pagination() not working in wpquery
  63. How to use two meta_compare in an array?
  64. How to override url params with rewrite rules vars?
  65. WP_Query: getting posts where custom field exists
  66. How to show meta value code HTML after x paragraph
  67. Form search query – displaying ACF “Post Object” field as results
  68. WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
  69. Convert a string into a decimal number for use in query
  70. How to display SQL query that ran in WC_Order_Query?
  71. get_the_ID() doesnt work
  72. Array to string conversion on array_map
  73. Store metakey value as an array
  74. Increment paged on WP_Query
  75. Target post_date_gmt if it’s empty or not set
  76. Hide posts if user is added to it WP_query
  77. Remove empty terms from array, sort alphabetically, update back to repeating field
  78. WordPress loop by meta key that is an array? and how loop multiple arrays
  79. WordPress yoast seo plugin – parse snippet var in meta description
  80. Custom route and query
  81. change the default order of posts only for specific categories
  82. Getting posts to exclude from array
  83. Get all posts as an array ID => Name
  84. How to store multiple custom meta box
  85. How to hide posts of a specific custom category in WordPress?
  86. How to insert wp_users ->user login name to wp_terms when a new user registering?
  87. Post not populating for custom post type based on category selection
  88. Passing an array into WP_Query as a variable
  89. Custom query vars filters problem with pagination
  90. Custom post type permalinks do not appear using the link functions
  91. WordPress meta_query >= &
  92. extract serialized array to use for wp-query
  93. Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
  94. WP_Query multiple post results
  95. How to add post meta in while loop?
  96. Add category to post meta
  97. Modify main query before it run without pre_get_post
  98. WordPress WP_Query without query GET parameters
  99. Using rules in Posts
  100. Sort posts in a specific way
Categories PHP Tags php, post-meta, wp-query
.htaccess too many redirects based on category slug
What is this code trying to do? It was the cause of my 20s TTFB

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress