Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
  • in reply to: Exclude Category from KLEO Ajax Search #146677
     proteus
    Participant

    Hello I tried this and it did not work. The results in the top search bar still return a list of posts from the category that I do not want visible.

    Below is what I have added to the child theme functions.php file.

    I have attached an image.

    COPY CODE
    /**
    	* EXCLUDE INTRAHUB CATEGORY FROM SEARCH AJAX EXCEPT FOR USERS THAT ARE ADMINS OR PROTEUS
    */ 
    
    function sq7_altering_ajax_search($defaults){
    	if ( current_user_can('proteus') || ! $query->is_main_query() ) {
    		return;
    	} else { 
    		$defaults['cat'] = '-1230';
    	}
    }
    
    apply_filters( 'kleo_ajax_query_args', 'sq7_altering_ajax_search');
    
    /**
    	* EXCLUDE INTRAHUB CATEGORY FROM SEARCH EXCEPT FOR USERS THAT ARE ADMINS OR PROTEUS
    */ 
    function wcs_exclude_category_search( $query ) {
      if ( current_user_can('proteus') || ! $query->is_main_query() )
        return;
    
      if ( $query->is_search ) {
        $query->set( 'cat', '-1230' );
      }
    
    }
    Attachments:
    You must be logged in to view attached files.
Viewing 1 post (of 1 total)

Log in with your credentials

Forgot your details?