Hi,
Is it possible to make password protected pages appear in search results?
No worries, found this code that worked.
// include password protected pages in search results
add_filter( ‘posts_search’, ‘include_password_posts_in_search’ );
function include_password_posts_in_search( $search ) {
global $wpdb;
if( !is_user_logged_in() ) {
$pattern = ” AND ({$wpdb->prefix}posts.post_password = ”)”;
$search = str_replace( $pattern, ”, $search );
}
return $search;
}
Actually, one small problem still.
Protected pages are still not showing in the search box as you type, when you hit enter, they appear, but not until you hit enter.
Is there any way to fix this you can share, please?
Hi WordPressed,
Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you :)
Best regards,
Victoria