Forums › Forums › Search & Filter Pro › ACF, Post Meta, Relevanssi conflict
- This topic has 2 replies, 2 voices, and was last updated 4 years, 3 months ago by Trevor.
Viewing 3 posts - 1 through 3 (of 3 total)
-
Anonymous(Private) September 21, 2020 at 6:20 pm #260217
Hi, I am currently using Advance Custom Fields and Relevanssi to search my custom post type. Before implementing Relevanssi I was using
sf_edit_query_args
to edit the$query_args
to filter by the current logged in user based on meta data.Since adding Relevanssi the filter
sf_edit_query_args
no longer works. I receive 0 results whenever attempting to search. I also attempted to edit the “Post Meta” tab on a form and that yields the same results.Is there any way to use Relevanssi and still filter based on post meta data?
Anonymous(Private) September 21, 2020 at 6:37 pm #260220I was able to fix my issue. Here is my code snippet in case anyone runs into the same issue…
function set_user_di( $query_args, $sfid ) { //if search form ID = 225, the do something with this query $nam_options = get_option( 'nam_options' ); $inventory_form_id = (int)$nam_options['my_inventory_form_id_number']; if ( is_user_logged_in() && $sfid==$inventory_form_id ) { if ($query_args['meta_query']) { array_push($query_args['meta_query'], array( 'key' => 'owner', 'value' => get_current_user_id(), 'compare' => '=', )); } else { $meta_query = array( array( 'key' => 'owner', 'value' => get_current_user_id(), 'compare' => '=', ), ); $query_args = $meta_query; } } return $query_args; } add_filter( 'sf_edit_query_args', 'set_user_di', 20, 2 );
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)