Skip to content

Instantly share code, notes, and snippets.

@tannerm
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tannerm/10015354 to your computer and use it in GitHub Desktop.
Save tannerm/10015354 to your computer and use it in GitHub Desktop.
Password protect content.
<?php
/**
* Redirect password protected content to it's own file
*/
function tm_password_protect_redirect() {
// if password is not required or has been entered, continue with standard behavior
if ( ! post_password_required() ) {
return;
}
// if password is required and is not found, include protected template
get_template_part( 'protected.php' );
exit();
}
add_action( 'template_redirect', 'tm_password_protect_redirect', 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment