How to allow password protected content in search results (4 posts)

  1. utahportraits
    Posted 5 years ago #

    The search widget does not display password protected content (posts, specifically) in the results. I need it to!

    I've tried the "Search Unleashed" plugin, and it didn't work for me. Neither did deactivating all other plugins, or the theme itself.

    Removing the password protection made the posts searchable, but that's not an option for me. It does show it's the password protection that is the issue, though.

    Any help? Thanks.

  2. Beyond Creative
    Posted 4 years ago #

    Hey, did you ever get to solve this problem? I'm having the same issue. I need help desperately. Thanks!!

  3. webmaster@statepublicadjuster.com
    Posted 4 years ago #

    I am having the very same issue....anybody come up with a solution...It would be a great help.

    I have a client that wants to post status of projects. When his customers go to the search box they type in their unique client number. It takes them to the search results page that has their customer number as the title of the post. They type in their password and gain access to their status....sounds simple enough eh?

    Any help would be greatly aprreciated. In the mean time...back to the forums for more exhausting topic searching on the topic.


  4. webmaster@statepublicadjuster.com
    Posted 4 years ago #


    Add this code to your functions.php file and you will get it to work.

    add_filter( 'posts_search', 'include_password_posts_in_search' );
    function include_password_posts_in_search( $search ) {
    	global $wpdb;
    	$pattern = " AND ({$wpdb->prefix}posts.post_password = '')";
    	$search = str_replace( $pattern, '', $search );
    	return $search;

Topic Closed

This topic has been closed to new replies.

About this Topic