Forums › Forums › Search & Filter Pro › S&FP custom query with ACF field
- This topic has 3 replies, 2 voices, and was last updated 5 years, 10 months ago by Trevor.
-
Anonymous(Private) January 15, 2019 at 11:28 am #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(Private) January 15, 2019 at 12:04 pm #198939With 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.Trevor(Private) January 15, 2019 at 12:10 pm #198947Pretty 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?
-
AuthorPosts