Skip to content

Instantly share code, notes, and snippets.

@duaneleem
Created April 11, 2018 19:06
Show Gist options
  • Save duaneleem/d2f3a19734ef956c2e65be82cc26960e to your computer and use it in GitHub Desktop.
Save duaneleem/d2f3a19734ef956c2e65be82cc26960e to your computer and use it in GitHub Desktop.
WordPress private page.
<?php
/**
* This template is used for displaying PRIVATE pages.
*
* Template Name: Private: Full Width
*/
get_header(); ?>
<div class="wrapper section medium-padding">
<main class="section-inner clear" role="main">
<?php
$content_class = is_active_sidebar( 'sidebar-1' ) ? "fleft" : "center";
?>
<div class="content clear <?php echo $content_class; // WPCS: XSS OK. ?>" id="content">
<?php
if (!is_user_logged_in()) {
echo "
<h1 style='font-size: 2em; font-weight: bold;'>Unauthorized Access</h1>
<p style='margin-top: 40px;'>You must be signed in to view this content!</p>
";
wp_login_form(array("echo" => true));
} else {
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', 'page' );
endwhile; else :
get_template_part( 'content', 'none' );
endif;
}
?>
</div> <!-- /content -->
<?php get_sidebar(); ?>
</main> <!-- /section-inner -->
</div> <!-- /wrapper -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment