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
- Determine if page is the Posts Page
- Keyboard shortcut for updating a page or post?
- Difference between an archive and a page listing posts
- 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?
- disable password protected page for logged users
- RSS for Pages Instead of Posts?
- Pagination for Pages and Posts
- Can I change a post to a page by changing it’s type?
- Overview with latest edited posts and pages
- Add a custom option to a page in backend
- How do I approach removing menu items on the fly based on settings in my plugin?
- Creating new page with pre-defined parent page
- Why does `url_to_postid` return 0 when testing `page_for_posts` Page?
- Populating a page with content from post custom fields
- What Defines What Category A Post Picks (if in multiple)
- Changing my permalink structure – will new layout conflict with existing page?
- Can a page_id and a post_id be same?
- Differentiate between posts and pages in search results
- Getting a 404 error when clicking edit page
- Why content_arr[‘extended’] removes paragraph tags?
- Get latest posts from WordPress site without header, menu and sidebar
- How can I schedule a PAGE to go live at a future date/time?
- Is it possible to change post id for an already added menu item in WordPress?
- How to insert 2 args into 1 Wp_Query for a slideshow
- More then one menu items are assigned with “current-menu-item” class
- Second comments section for one post/page
- How to list recent posts in a wp nav menu?
- 404 error on default post type and default taxonomy fronted page
- 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?
- wp_list_categories() Exclude All Categories Except One
- Direct some posts to only appear on a specific page
- 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!
- 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
- Precedence of page permalinks over woocommerce product category links?
- 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
- 404 error on every post and page other than home
- “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?
- Dynamic Menu Item
- Automatically search and replace link in content (pages/posts)?
- How to remove slug from CPT correctly?