Forums Forums Search & Filter Pro Don't show password-protected posts in search results?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Anonymous
    #215041

    Hello, I’m looking for a way to exclude password-protected posts from showing up in search results. This is for the standard WP password protection feature. I don’t see the option in the Posts or Post Meta tabs. Is this possible? Thanks.

    Trevor
    #215054

    Such posts are showing in the results? I am not sure that they should be. Are you able to send me a live link/URL to your search page so I can take a look? Give me a search I can do and let me know which post in the results is password protected?

    Anonymous
    #215108

    Unfortunately as the site is in development and behind our firewall, you can’t access it. I took a screenshot of the search results, though, and I can send it to you if you let me know the best way to do that. The posts are public (custom post type) but password-protected. Thanks.

    Trevor
    #215112
    This reply has been marked as private.
    Anonymous
    #215131
    This reply has been marked as private.
    Trevor
    #215133
    This reply has been marked as private.
    Anonymous
    #215139

    Thanks. I send you a screenshot, but if it’s helpful I can initiate a call. I am in East Coast US time — not sure if it’s too late in the UK.

    Trevor
    #215143

    I think you will need to use this filter (the code goes in to your child theme functions.php file):

    https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments

    Like this:

    function exclude_password_protected_posts( $query_args, $sfid ) {
    	if($sfid==225)
    	{
    		$query_args['has_password'] = FALSE;
    	}
    	return $query_args;
    }
    add_filter( 'sf_edit_query_args', 'exclude_password_protected_posts', 20, 2 );

    where you need to change the ID number (in the example it is 225, so use the ID number of your form).

    Anonymous
    #215145

    That did the trick. Thanks so much.

Viewing 9 posts - 1 through 9 (of 9 total)