• Hi guys, please help me if you can.

    I’ve been setting up my site using WordPress for the first time. It’s primarily a portfolio site with a blog as well. Essentially all the pages in the site pull in posts from the same WordPress database, only I’ve categorised each post in order to aggregate them to different pages. If you want to view the site it’s here:

    https://richdean.co.uk/testpress/

    It’s basically four pages – Portfolio (which is the front page), Private Work (which should work the same as Portfolio but be password protected as it’s going to have confidential work), About Me, and Blog.

    I’m not using the default ‘Home’ page, as I want different posts showing on some pages and not on others so I’ve set up Portfolio to be my front page.

    So all the pages pull in posts from the same WordPress database, only the posts are categorised so that different posts can appear on different pages. To do this, I used a bit of query php that I found in the support articles on here, which goes before the ‘loop’. I basically took the default template for a page with no sidebar, duplicated it for each individual page, gave each of the pages a unique template name, and inserted this code into each of them:

    <?php /*
    Template Name: Private Work
    */ ?>

    <?php get_header(); ?>

    <!– mid content –>
    <div id=”mid-content”>
    <?php if(have_posts()) : ?>

    <?php
    if (is_page()) {
    query_posts(“category_name=private_work”);
    }
    ?>

    <?php while(have_posts()) : the_post();
    ?>

    So this is the code just for the Private work page. It’s repeated on the other pages, only with the names changed to reflect that particular page.

    Each of the pages works fine – I can pull in whichever posts I want to each page, which is all good.

    The problem now is that the Private Work page is meant to be password protected, only this doesn’t work now.

    If I go into wp-admin and change the template from my custom version back to the default one, the password protect does work, but now the posts aren’t being pulled in. If I change it back to my custom template, the posts work but the password protect doesn’t, even though both templates are exactly the same apart from the query code in the loop.

    Can someone please help me out?

    Thanks in advance! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Does the title of the private work page really have an underscore in it? Or should that be query_posts("category_name=Private Work");?

    kmsultan

    (@kmsultan)

    How you found a solution to this. It’s exactly the problem I’m facing right now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Password Protect Wont Work’ is closed to new replies.