Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Hiding content (e.g., ) conditionally if search has been performed › Reply To: Hiding content (e.g., ) conditionally if search has been performed
Hi,
Thank you for the details!
If I understand correctly, you have the auto-populate feature enabled, which shows some results. Then when the user changes a filter or enters a new phrase a new search is initiated, but this time you want to exclude some results from this and all succeding queries. Is that correct?
If so, I think there is a very simple way to do it programmatically via the asp_query_args hook:
add_filter('asp_query_args', 'asp_exclude_on_non_autopopulate', 10, 1);
function asp_exclude_on_non_autopopulate($args) {
if ( !$args['_is_autopopulate'] ) {
$args['post_not_in'] = array(1, 2, 3, 4); // Exclude posts by ID
}
return $args;
}
This code will exclude the items by IDs from the array, if the current search quers is not the auto-populate query.