If you want to check if a post has a password, and that the password has been entered, check both post_password_required() and $post->post_password:
$post = get_queried_object();
if ( ! post_password_required( $post ) && ! empty( $post->post_password ) ) {
// Post has a password, but has been entered.
}
Related Posts:
- Using WP page password protection as defacto login
- Apply the_title() filter in post & page title, but not in menu title
- Edit menu item title from edit page/post
- Disable most recent & view all (TABS) on nav-menu.php
- Using wp_list_pages() after calling query_posts()
- disable Tab post on nav-menus page (Admin)
- Making a new post visible on a specific page
- Go back to the exact post page number
- Parent menu item does not display posts when I add the sub-items
- I lost the link to my posts in my menu bar
- Page and Posts loading as index page? Not loading the content
- Call posts of particular category in a page
- Add custom class to existing menu items from custom meta
- How to make posts appear under pages
- Adding a post to a page
- Get the Current Page Number
- Stop WP from creating “Sample Page” and “Hello World!” post
- How to display by default only published posts/pages in the admin area?
- The next_posts_link() works only with original $wp_query
- Using single.php from plugin folder instead of default template folder
- Skipping first 3 posts in wp query
- How to display the page title/content in the Posts page?
- Callback for wp.autosave.server.triggerSave();
- How can I see a list of pages and post where my custom Gutenberg block is used?
- RSS for Pages Instead of Posts?
- Adding Post Counts to Menu (Nav) Programmatically?
- Set number of article per number of page
- Pagination for Pages and Posts
- Can I change a post to a page by changing it’s type?
- Add a custom option to a page in backend
- Creating new page with pre-defined parent page
- Populating a page with content from post custom fields
- What Defines What Category A Post Picks (if in multiple)
- Making WordPress’ page and menus visible only for logged in users, checking session variables
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- disable column on post and user list
- WP_Query do not load specifed number of post
- Can a page_id and a post_id be same?
- How can I display widget in a Page or Post?
- Differentiate between posts and pages in search results
- Getting a 404 error when clicking edit page
- Specifying # of Posts per page using inline post plugin (:
- Can I use images as anchor tags with
- Create posts under certain page
- Should I use posts or pages in this scenario?
- Switch to page template when using post permalink
- How to handle broken links created by permalink/slug changes?
- How to list recent posts in a wp nav menu?
- 404 error on default post type and default taxonomy fronted page
- When open add new post or page WordPress add post with ID=0 continuously [closed]
- How do I do a page break?
- When changing pages to posts, how do you set up 301 redirects for the page URLs?
- 2 dynamic sidebars registered, not showing up
- Including link to custom post type in ‘wp_list_pages’ function
- How to make default “Privacy Policy Page” a normal page?
- static landing page leading to author specific pages w/ “live” content
- Total number of posts in query (category/tag/author/search results/main page…)
- WordPress Menu options in the Admin: Posts for the dropdowns
- Automatically add images to a menu
- Echo Text If User Is Logged in But NOT the Author of post
- WordPress 302 Redirect to Random Product/Post/Page
- New Posts and Pages Won’t Save
- Get current post’s nav menu name (term name)
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- Different post views for different category views
- Changing permalink of WordPress
- Indenting within a blockquote
- Featured Images most often doesnt appear
- Create a List of Widgets, where each widget holds three attributes
- Change published date and time using SQL query for page in every 5 hour
- Is there a way to know when a page has been updated and do some action only once?
- WordPress Sticky Post Count “Fix” Breaking Pagecount by 72 pages!
- How to add class to specific navbar item when post parent category is in specific category
- Put page on Archived statut after end of publication date
- How to add a block to a category page?
- post and page and custom post type
- calling pages instead of posts
- WordPress display page information rather than post
- Post Category link is same with Page link
- Is it possible to query a category with specified posts?
- How do I set content in my pages so that it remains permanent while blog posts are added below?
- Permalink base only for posts
- Is there a global page/post/product/anything ID?
- WordPress URL question
- Theme does not respect spaces between paragraphs in pages
- My blog “page” used to show a list of posts, but now it’s just showing the page content?
- Converting Posts to Pages
- “Current” class on a singular page menu item with custom post types?
- get next/previous post name
- Get post title of faulty link on 404 error page
- Get current post’s child page?
- The next_posts_link() works only with original $wp_query
- Limit amount of pages shown in pagination within wp_query
- how to show all type of author posts in author page (SOLVED)
- custom post type single page template not working
- WordPress Page Column Problem [closed]
- What function does the loop of displaying posts?
- Header and Footer options in pages and posts
- Blog posts are not appearing as subs of Blog Page
- Blog Posts Work in Preview, But Are Not Visible on the Live Page – READ MORE u003cspan aria-hidden=’true’u003e→u003c/spanu003e Error