Hide private / password protected content

Display Posts can be used to list – or exclude from listing – any content you’ve marked as “Private” or set with a password.

Private Content

Display Posts does not show private posts by default. It limits results to content with the “publish” status.

If you create a private page, then use [display-posts post_type=”page”] to list pages, your private page won’t be included.

If you change the shortcode to [display-posts post_type="page" post_status="publish, private"] it will appear. Here’s a list of all available post statuses.

Password Protected Content

Password protection isn’t a post status, but rather an attribute of the post. Default listings include content with and without passwords.

You can customize the results using the has_password parameter.

[display-posts] Displays all posts (with and without a password)
[display-posts has_password="false"] Displays posts without a password
[display-posts has_password="true"] Displays posts with a password

Published by Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributor to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Leave a comment

Your email address will not be published. Required fields are marked *