• Hello,

    I need to exclude protected (private) posts from the ajax search, do you know if there’s a way to achieve this? I see there’s an option ‘Post statuses to search’ in the main settings, which I set to ‘publish, future’ as you can see in this screenshot here : https://paste.pics/57b19d9955155a68583226aad05a7bc2 but it doesn’t work. If you type ‘Prova auto’ in the search you will see a protected post come out.

    Do you know if there’s a way to solve this? thanks a lot for any support!
    Francesco

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi,

    Well password protected posts are not actually ‘private’ in status, but published. However, with a custom code it might be possible. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter( 'asl_results', 'asl_exclude_passw_protected', 10, 1 );
    function asl_exclude_passw_protected($results) {
    	foreach ( $results as $k => &$r ) {
    		$post = get_post( $r->id );
    		if ( !empty( $post->post_password ) ) {
    			unset($results[$k]);
    		}
    	}
        return $results;
    }

    Best,
    Ernest M.

Viewing 1 replies (of 1 total)

The topic ‘Exclude protected posts from search’ is closed to new replies.