Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macariojames/0ab5db0ad5da1c0711424aa85cbe9b56 to your computer and use it in GitHub Desktop.
Save macariojames/0ab5db0ad5da1c0711424aa85cbe9b56 to your computer and use it in GitHub Desktop.
Remove password protected posts from the Loop
<?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