conditional tags - Hide a template part when page is password protected?

I'd like to hide the sidebar of my page when the page is password protected and the password has not yet been enter

I'd like to hide the sidebar of my page when the page is password protected and the password has not yet been entered.

I've searched for a while and haven't found any condition I could use. Maybe get_post_status could help, but still, I wouldn't know when the user has entered the password and can see the full page.

I'd like to hide the sidebar of my page when the page is password protected and the password has not yet been entered.

I've searched for a while and haven't found any condition I could use. Maybe get_post_status could help, but still, I wouldn't know when the user has entered the password and can see the full page.

Share Improve this question edited Mar 11, 2014 at 17:07 Fredy31 asked Mar 11, 2014 at 15:33 Fredy31Fredy31 8782 gold badges16 silver badges31 bronze badges 2
  • Please edit your question to clarify. Private posts are not the same thing as password-required posts. Which are you after? – Chip Bennett Commented Mar 11, 2014 at 16:14
  • Sorry, seems that when I wrote the article I was mixing up password required and private. Modified the question to make it easier to understand. – Fredy31 Commented Mar 11, 2014 at 17:08
Add a comment  | 

1 Answer 1

Reset to default 4

You're after post_password_required():

<?php if ( ! ( $post->post_password && post_password_required() ) ) get_sidebar() ?>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745157549a4614213.html

相关推荐

  • conditional tags - Hide a template part when page is password protected?

    I'd like to hide the sidebar of my page when the page is password protected and the password has not yet been enter

    12小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信