The reason why you are getting a not redirecting properly
message is because you are creating an endless loop of redirects. They get redirected to /public
but because they are not logged in they get redirected again and again and again…
Try this code instead:
if( ! is_user_logged_in() && ! is_page("public") )
{
wp_redirect( site_url("/public") );
exit;
}
I’m assuming that /public
is a page you have setup.