Forums › Forums › Search & Filter Pro › Including ACF Post Meta in Results
- This topic has 7 replies, 2 voices, and was last updated 7 years, 2 months ago by Anonymous.
-
Anonymous(Private) August 22, 2017 at 6:35 pm #127149
I have a filter set up to find all posts with a relationship to an ACF called “people”, it returns all results with a relationship to a “person” post but I would also like to return the “person” post itself in the search results.
What is the easiest way to include it in my results?
I have tried something like this:function people_filter( $query_args, $sfid ) { if($sfid == 7287) { if ($_GET["_sfm_people"] != "") { $query_args['p'] = intval($_GET["_sfm_people"]); } } return $query_args; } add_filter( 'sf_edit_query_args', 'people_filter', 10, 200 );
But this returns the “person” post only, I would instead like to add it to the already compiled results.
Anonymous(Private) August 23, 2017 at 9:44 pm #127340Hmm, I’m getting an empty array. My code:
function people_filter( $query_args, $sfid ) { if($sfid == 7287) { echo '<pre>',print_r($query_args,true),'</pre>'; } return $query_args; } add_filter( 'sf_edit_query_args', 'people_filter', 10, 200 );
It’s strange because the archive page is displaying results, maybe it’s firing too late?
Anonymous(Private) August 23, 2017 at 11:13 pm #127343It was actually firing too early. Still I can’t seem to add the post to the results.
Here is my code:function people_filter( $query_args, $sfid ) { if($sfid == 7287) { if ($_GET["_sfm_people"] != "") { array_push($query_args['post__in'], intval($_GET["_sfm_people"])); echo '<pre>',print_r($query_args,true),'</pre>'; } } return $query_args; } add_filter( 'sf_edit_query_args', 'people_filter', 20, 2 );
And here is what the print_r is echoing:
Array ( [paged] => 1 [search_filter_id] => 7238 [search_filter_override] => [posts_per_page] => -1 [post_status] => Array ( [0] => publish ) [meta_query] => Array ( ) [post_type] => Array ( [0] => lesson [1] => people [2] => video [3] => image [4] => article ) [is_search] => 1 [post__in] => )
-
AuthorPosts