• Hi !

    I have a website with a personnalize theme. I created the theme with a tutorial on Internet few years ago.
    Today, I try to protected one of my page with a password. Unfortunately, I had not add code to do that when I created my theme…
    So when I check “protected with a password” during the creation of a page, it does not work.
    How can I add code to have this possibility on my theme ?

    Thanks a lot for your answer.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello zazzou,

    I did a little research, and from what I can see adding “visibility: password protected” will add the password to that page/post but the post can still be seen in Archive pages and in the homepage.
    I found this article (the part you are interested is at the bottom “Hiding Password Protected Posts Completely From Homepage and Archives”), that helps with that.
    https://www.wpbeginner.com/beginners-guide/how-to-password-protect-posts-in-wordpress/

    Be aware this is random code found in the internet! Test it on a localhost or a test site that is not online!

    If this helps, please mark the Status as solved,
    Thanks
    S.

    • This reply was modified 7 years, 8 months ago by Sol.
    Thread Starter zazzou

    (@zazzou)

    Hi,
    I am sorry but this link does not help me…
    I find a part of the answer : I would like to protect a template page. On this template page I had code directly and not
    <?php the_content(); ?>

    So in the wordpress code there is a code where we can have “when the user protect a page, so you protect the content of the page”. Where can i see that ?

    Thanks

    • This reply was modified 7 years, 6 months ago by zazzou.
    • This reply was modified 7 years, 6 months ago by zazzou.

    So you want to do it at the theme level. Do you wish to protect only posts? or just certain Pages? or the entire site?

    Let me know

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add code to protected pages’ is closed to new replies.