Support

Account

Home Forums Add-ons Gallery Field Empty array when ordering posts by meta_value Reply To: Empty array when ordering posts by meta_value

  • The issue for me was specific to $query->set('s', ' ');. I added it to fix empty search queries returning a 404 page.

    I set a bunch of other query vars in the same function but going through one by one, this was the only one to cause error.

    Btw, you’re missing a single quote before date_published.

      
    function property_filters($query) {
    
      // ...
    
      /**
       * Fixes issue with blank search queries returning 404
       */
      if (!is_admin() && isset($query->query_vars['s']) && empty($query->query_vars['s'])) {
        $query->set('s', ' ');
      }
    }
    add_action('pre_get_posts', 'property_filters');