This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Excluding specific Pages, Articles and Posts from search

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Excluding specific Pages, Articles and Posts from search Reply To: Excluding specific Pages, Articles and Posts from search

#30269
Ernest MarcinkoErnest Marcinko
Keymaster

Well, I think yes, but will require custom coding for sure. The asp_query_args hook allows appending/changing the search arguments. You could start with something like this:

add_filter("asp_query_args", "asp_query_args_change", 10, 2);
function asp_query_args_change($args, $search_id) {
	if ( current_user_can('editor') ) {
		$exclude = '1,2,3,4'; // Exclude posts IDs 1, 2, 3 ,4
	} else if ( current_user_can('manage_options') ) {
		exclude = '4,5,6';
	} //...
	
	// No changes below
	$args['post_not_in'] = array_unique(array_merge(
		$args['post_not_in'],
		explode(',', str_replace(' ', '', $exclude))
	));
	return $args;
}