Forums Forums Search & Filter Pro S&FP custom query with ACF field

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #198936

    Hi,

    We have set-up a custom query with an ACF relationship field.

    This works without S&FP.

    When we add 'search_filter_id' => 4356, to the WP Query, suddenly all posts are shown and not only the ones we defined in our WP_Query. (when we comment it out, it works)

    Below the full code

    	
            // Get account linked to logged in user
    	$account = get_field( 'field_5c3a01aa0a32e', 'user_' . get_current_user_id() );
    	
    	// Get lassers from that account: returns array of ID's
    	$lassers = get_field( 'field_5c3a0bb483f86', $account[0]->ID );
    
    	// args Query
    	$args = array(
    		'post_type'      => 'lasser',
    		'posts_per_page' => -1,
    		'post_status'    => 'publish',
    		'order'          => 'ASC',
    		'search_filter_id' => 4356,
    		'post__in'       => $lassers,
    
    	);

    We also tried the filter sf_edit_query_args but that doesn’t work either.

    Any idea why the above isn’t working/

    Trevor
    #198939

    With regard to post__in, I am sorry, but you cannot update (in the filter sf_edit_query_args) that variable, and if used in $args, it is overwritten by our argument, because (after that filter is run) S&F does all the calculations from the cache, and replaces the post__in variable completely.

    Anonymous
    #198941

    Hi Trevor,

    Thanks for the feedback.

    Can we work with meta_key and meta_value?

    Trevor
    #198947

    Pretty much any other variable you can work with.

    As a thought. Our plugin does it’s stuff and then sends a simple list of IDs to the database to get the posts. You must be able to get that list and then compare the arrays and the run your own query?

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