Make wordpress require login for all pages

If you’re building a site, you don’t want the public to be able to access it, especially if there’s legal requirements it doesn’t meet yet.

Easiest way to do this: put

if (!is_user_logged_in()) {

at the start of your wp-content/themes/<your theme>/header.php.

Warning: If you update or change your theme, you’ll re-enable login. This might as well be a good thing – if you can’t remember how you made your site require login, and want to remove the feature, just reinstall your theme.

Leave a Reply

Your email address will not be published. Required fields are marked *