Support

Account

Forum Replies Created

  • What happens if you add $query->is_main_query() to your if statement?

    
    function allstar_buzzworthy_published_sort( $query ) {
            // If not the admin section
            if ( !is_admin() &&  $query->is_main_query()) {
                // If on a taxonomy page
                if ( is_tax() ) {
                    $query->set( 'meta_key', 'date_published' );
                    $query->set( 'orderby', 'meta_value' );
                    $query->set( 'order', 'DESC' );
                }
            }
        }
        add_action( 'pre_get_posts', 'allstar_buzzworthy_published_sort' );
    
  • 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');
    
  • I am also seeing the same behaviour after upgrading to Gallery 1.1.0 and ACF 4.3.0.

    With add_action('pre_get_posts'... called in functions.php, get_field for a gallery field returns an empty array.

    If I comment out the pre_get_posts action everything works as expected.

Viewing 4 posts - 1 through 4 (of 4 total)