My random sorting of custom posts isn't working since I upgraded to WordPress 5.4. This is the query that I am using:

      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $args = array(
        'post_type' => 'client',
        'post_status' => 'publish',
        'posts_per_page' => '7', // you may edit this number
        'paged'                 => $paged,
        'orderby'           => 'rand',
        'meta_query'        => array ( array ('key' => 'wpcf-featured-post', 'value' => '1', 'compare' => '='))

      $client_items = null;
      $client_items = new WP_Query($args);

Has something changed in 5.4 to sort posts randomly?

Thank you.

  • Nohting has changed to sort posts. Have you made any other change in your site? Could check the actual query that is performed? Something like var_dump( $client_items ) could help to debug. – cybmeta Apr 9 at 18:33
  • Thank you for your answer. I found the problem, the plugin Post Types Order was adding an orderby menu id to all queries. Unchecking an option in it's settings has fixed the issue. – Laurelle Apr 11 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.