Try reversing the condition :
if(post_password_required( )):
echo get_the_password_form();
else:
// if password not required or password cookie is present
// your protected content here
endif;
See codex
Hope that helps.
Related Posts:
- To close or not to close php
- Is there a way to parse shortcodes in PHP?
- Displaying a WooCommerce product via PHP
- Static Frontpage Pagination – Custom loop
- Get the php template file from other theme folder
- wp_remote_get returns an error for valid URL
- How to loop over custom fields in a page template?
- Use Timber/Twig to pull an image by image ID [closed]
- Categories Template Assistance
- Unable to set right time in admin and frontend template
- Easiest way to show total number of subpages
- Switching between custom templates in a post type of the admin menu
- Use template for posts with a particular category grandparent
- Blank space at beginning of tag?
- Add a Second Menu to a theme that only support 1 menu
- Custom excerpt function re-factoring
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- How to display user nickname (not display name) in PHP template?
- Custom Template 404 for specific custom post type
- Custom field value not saving when it contains a URL?
- Automatically add custom CSS to new posts using a category template
- How can I load a PHP page without using a Template?
- how could I load a different template part by page
- creating a second image attachment template?
- Get and insert order email address to the PHP template inside HTML text
- How to limit the number of forgot password reset attempts in WordPress?
- How to show single category archive
- code is skipping a div
- Issues getting PHP to display in category pages
- Secondary navigation menu on one page
- Enable custom logo upload if logo is not in header
- Styling my own password protected page, how to deal with wrong password?
- how to show only specific category for a template
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Using same variable names in files added with get_template_part()
- Use WordPress function in php file
- Add filter multiple times using only one master function
- Create a Blog Template Page
- Showing latest post without 301 redirect
- WordPress template page name displayed on screen
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- single.php with different look by category
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Removing WordPress Footer -without access to PHP code?
- How to set a template with wp_insert_post
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Adding conditional text to a PHP Shortcode Template
- Create page template via functions.php?
- What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
- how to display this functions?
- is_page_template showing partial results
- Adding regular php file to site
- add_filter function concatenate string and locate_template function
- How do I create a function that modifies a message in the wp-login.php file?
- Template Loop – add switch case php
- WordPress produces identical hash all the time
- Change page password every day (predictable password ;) )
- Post repeated when opening in overlay, how do I solve this? [closed]
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- Splitting the_content() by size?
- Gravity Forms merge tags in templates?
- Unable to render custom field after attempt to generate a list of recent post in page template
- php loading different structure than source code
- pass html code to worpdress
- Remove password protection from all posts
- Getting a WordPress tag to print inside of a traditional php echo
- Loading Elementor templates in a Bootstrap modal on button clicking
- Prevent header and footer from loading on specific pages with template or plugin
- Require()/Include() post template adding extra content
- Display metabox galleries on specific page template in admin editor
- Display WordPress archive template page in 3 columns and not 1 column [closed]
- Run do_shortcode on php template using JS function
- How to hardcode header and footer in WP?
- What are the advantages/disadvantages of ways to use php template files?
- Change the “Show All” button in a WordPress Portfolio Filter
- Check if current post in loop is last on current page
- Roots Sage Symfony error when using override from template
- If is_page elseif is_page not working like I want it to
- Redirecting the lost password page request when using a custon login page
- How to display last whole post on the homepage
- missing admin bar and widget in a template
- How to include a function in a template with template tag
- My own theme’s custom widget areas are not working
- Issue encountered while trying to keep website private
- Add point on excerpt post
- WooCommerce – Print Processing orders [closed]
- Loop returns more items than exist?
- How to call a certain object/menubar in a PHP file
- why is this content-template not showing any of my blog-entries?
- how to register a second page-template
- why is markup routinely placed in functions in wordpress?
- PHP code rendered in HTML
- Password form redirection to belonging post
- If I define a variable in header.php, how do I make it available to templates?
- php “use” not working in template [closed]
- Loop on a wordpress Page instead of content coming from the WP text editor
- How can one use variables in a template or template part without polluting the global scope?
- Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)
- How to send user password reset link to their phone number instead of email