Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I try to password protect my custom page such that before any content is shown the user must enter a password. More specific, in my code below, anything inside the content-div-container should be password protected:

<?php
/*
Template Name: custom_page
*/
?>

<?php get_header(); ?>
<div id="content">

  <div id="main">


<ul class="post">
        <li><b>LATEST POSTS</li>
 <?php
    $args = array('category' => 5, 'post_type' =>  'post');
    $postslist = get_posts( $args );    
    foreach ($postslist as $post) :  setup_postdata($post); 
    ?> 
    <li id="post-<?php the_ID(); ?>">
      <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
    <?php the_excerpt(); ?>
    </li>
    <?php endforeach; ?>

</ul> 

</div><!-- end content -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

I tried to use the approach explained here

Password protecting a page

but cannot make it work, since I do not know how to wrap my php code into the suggested solution.

share|improve this question
1  
Please show how you tried, not what you need to get wrapped up (we don't know in detail). – kaiser Oct 5 '12 at 10:55

1 Answer

I would suggest using the Membership Plugin; it allows for users of a certain type to access to specified protected areas.

WordPress › Membership « WordPress Plugins

This can be applied to specific sections on a page.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.