Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #875443

    Hi,

    Is it possible to make password protected pages appear in search results?

    #875444

    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;
    }

    #875447

    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?

    #875532

    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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.