Display private posts in the WP search results for logged in users
-
Basically as the title says, I put this together a while back in my functions.php and it works:
// SHOW PRIVATE POSTS FOR LOGGED IN USERS function include_password_posts_in_search( $query ) { if ( is_user_logged_in() ) $query->set( 'post_status', array ( 'publish', 'private' ) ); } add_action( 'pre_get_posts', 'include_password_posts_in_search' );
The only problem is that this chunk of code is conflicting with WP and makes nothing display in my Media section / Individual Posts Gallery. Also I can list posts no problem but when I try to list published or private posts it says “no posts found” when the number of posts still shows there are some.
So this code is conflicting with something in WP but I can’t figure out what it is!
Thanks for your time 🙂
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Display private posts in the WP search results for logged in users’ is closed to new replies.