Last active
August 31, 2018 20:53
-
-
Save macariojames/0ab5db0ad5da1c0711424aa85cbe9b56 to your computer and use it in GitHub Desktop.
Remove password protected posts from the Loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // WordPress Stuffs! | |
// Add this to functions.php | |
// for removing password protected posts from the Loop | |
function wpb_password_post_filter( $where = '' ) { | |
if (!is_single() && !is_admin()) { | |
$where .= " AND post_password = ''"; | |
} | |
return $where; | |
} | |
add_filter( 'posts_where', 'wpb_password_post_filter' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment