WordPress.org

Support

Support » How-To and Troubleshooting » How to allow password protected content in search results

How to allow password protected content in search results

  • 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey, did you ever get to solve this problem? I’m having the same issue. I need help desperately. Thanks!!

    webmaster@statepublicadjuster.com

    @webmasterstatepublicadjustercom

    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.

    -Nick

    webmaster@statepublicadjuster.com

    @webmasterstatepublicadjustercom

    SOLUTION:

    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;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to allow password protected content in search results’ is closed to new replies.
Skip to toolbar