WordPress.org

Ready to get started?Download WordPress

Forums

Static Page with Password & Articles (4 posts)

  1. Nik S
    Member
    Posted 5 years ago #

    Hello everyone!

    Could any kind soul let me know how to have a password-protected static page with all blog posts that is different from the homepage (also static)?

    When I do this from the backend, the static page stops being pass-protected when I assign it to be my posts page from the drop-down menu of on the reading settings dashboard.

    Thanks, folks!

  2. MichaelH
    Member
    Posted 5 years ago #

    Duplicated your problem and reported via Trac Ticket 7862.

    Might have to password protect each post in the meantime.

  3. snagelcat
    Member
    Posted 5 years ago #

    Hi, was this ever resolved? I'm having the same problem

  4. Peter
    Member
    Posted 5 years ago #

    Hi,
    You cannot use the default wordpress setting to password protect your static page that you then set as your posts page if you follow.

    You need to set a custom template for your posts page.
    Create a new blank plain text document call it postpage.php and save it within
    /wp-content/themes/**the name of the theme your using/**

    Then when you create the page to show your posts in choose postpage as the template.

    As raw PHP put in the following to the blank text document postpage.php
    so you don't get your themes formatting with this;

    <?php
    /*
    Template Name: postspage
    */
    ?>
    <?php get_header(); ?>
    <?php
    $lastposts = get_posts();
    foreach($lastposts as $post) :
    setup_postdata($post);
    ?>
    <div class="item">
    <h2><?php the_title(); ?></h2>
    <p class="date"><?php the_time('j.m.Y') ?></p>
    <?php the_content(); ?>
    </div>
    <?php endforeach; ?>
    <?php get_sidebar(); ?>
    <?php include (TEMPLATEPATH . "/footer.php"); ?>

    To add in your themes formatting you'll need to copy the code from index.php within your themes folder and insert the above php in the right place. This would look something like this:
    <?php
    /*
    Template Name: postspage
    */
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes() ?>>
    <head>
    <?php get_header(); ?>
    </head>
    <body>
    <div class="main">
    <div class="container">
    <?php include (TEMPLATEPATH . "/head.php"); ?>

    <div class="content span-24">
    <div class="posts span-17 last">
    <?php include (TEMPLATEPATH . "/banner.php"); ?>

    <div class="paddings">
    <?php
    $lastposts = get_posts();
    foreach($lastposts as $post) :
    setup_postdata($post);
    ?>

    <ul class="items">
    <h2><?php the_title(); ?></h2>
    <p class="date"><?php the_time('j.m.Y') ?></p>
    <?php the_content(); ?>

  5. <?php include (TEMPLATEPATH . "/item.php"); ?>
  6. <?php endforeach; ?>

  7. <?php include (TEMPLATEPATH . "/missing.php"); ?>
  8. <div class="navigation">
    <div class="fl"><?php next_posts_link(__('« Older Entries', 'default')) ?></div>
    <div class="fr"><?php previous_posts_link(__('Newer Entries »', 'default')) ?></div>
    <div class="clear"></div>
    </div>
  9. </div>
    </div>

    <?php get_sidebar(); ?>
    </div>
    <div class="clear"></div>

    <?php include (TEMPLATEPATH . "/footer.php"); ?>
    </div>
    </div>
    </body>
    </html>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags