-1, 's' => esc_attr( $_POST['keyword'] ), 'post_type' => $anzu_header_search_post_types ) ); if( $the_query->have_posts() ) : echo '
'; while( $the_query->have_posts() ): $the_query->the_post(); ?> '; wp_reset_postdata(); endif; die(); } 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; }