adding logged_in to a custom page template
-
Hi,
I am trying to make a new custom page template that generates pages only for logged in users. I am having problems with the following code:
<?php /** * Template Name: Secure Page * * @package WordPress */ get_header(); ?> <div id="primary" class="site-content"> <div id="content" role="main"> <?php if (!is_user_logged_in()) { echo 'Welcome, this page is restricted to logged in users!'; } else { <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> <?php comments_template( '', true ); ?> <?php endwhile; // end of the loop. ?> } endif; //end of if-loop. ?> </div><!-- #content --> </div><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
Can anyone give me some pointers?
Thanks in advance!
- The topic ‘adding logged_in to a custom page template’ is closed to new replies.