Forums Forums Search & Filter Pro sf_edit_query_args not working with post__in

Viewing 2 posts - 1 through 2 (of 2 total)
  • Anonymous
    #195017

    I’m having problems filtering sf_edit_query_args with the post__in query arg. Here’s a quick prototype that I have:

    
    add_filter( 'sf_edit_query_args', function( $query_args, $sfid ) {
        if ( 20205 === $sfid ) {
            $query_args['post__in'] = array( 20696, 20694, 20612 );
        }
    
        return $query_args;
    }, 20, 2 );
    

    I double-checked that 20205 is the id of the search&filter form and that 20696, 20694, 20612 are actual custom post type ids. The form works as it should with the usual search&filter search field, custom post type filters, tag dropdowns, etc. But I’m not able to filter it programmatically with the provided post ids (however, it works correctly with a provided custom post type – $query_args['post_type'] = 'custom';). It simply returns no results. Is the post__in query arg not supported?

    Thanks!

    Trevor
    #195021

    Sorry, but you cannot update that variable, because after that filter is run, S&F does all the calculations from the cache, and replaces the post__in variable completely.

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