Home Forums General Issues Solved issue, but would like an explanation


Solved issue, but would like an explanation

  • So I was working on a Site which is being heavily modified.

    We started having Problems with saving anything except repeater fields, couldn’t set up new fields, after half an hour I deleted this code from my functions (which we rely on)

    //function to modify default WordPress query
    function reverse_posts_custom_query( $query ) {
            // Set parameters to modify the query
            $query->set( 'orderby', 'date' );
            $query->set( 'order', 'ASC' );
            $query->set( 'suppress_filters', 'true' );

    I then deleted a modification suggested by a Stackoverflow member (after I had some Problems with another function) and deleted

    $query->set( 'suppress_filters', 'true' );

    Now it’s working fine, I’m not 100% sure why, I have a hunch since it can hinder query-modifying Plugins to work, is this the case? Or is there another issues I am not aware off?

  • The reason is that your code appears to be modifying every query, your code will also modify any query made by acf or any other plugin or theme code. What you need to do is be more specific about what query you want to alter.

    // only modify the main query
    if ($query->is_main_query()) {
      // modify query
    // only modify queries on a specific post type
    if (isset($query->query_vars['post_type']) &&
        $query->query_vars['post_type'] == 'post-type-slug') {
      // modify query
  • Since deleting the suppress-filter it’s working fine for me and ACF is running like a charm again, no odd behavior whatsoever, but I know that it’s still affecting every query, I’m narrowing it down to certain Post Types.

    I just want to know if it’s the suppress-filter that interfered with ACF or am I overlooking something?

  • The best answer I have found so far

    It appears that setting this to true cases WP_Query to not call apply_filters() to many parts of the query. To be honest, I’m not sure what filters ACF uses, but I’ll have to assume, since it was giving you issues, that ACF does use whatever filters are being suppressed.

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

The topic ‘Solved issue, but would like an explanation’ is closed to new replies.