I would do it the other way around: Put the always visible text into a custom field per metabox, and protect the post content with a password.
In your theme, always show the custom field, and let WordPress handle the password protection.
Sample code for the theme:
while ( have_posts() )
{
the_post();
if ( post_password_required( $post ) )
{
print '<h1 class="post-protect-notice">' .
__( 'Protected Post', 't5_theme' )
. '</h1>';
the_excerpt();
// custom field
print wpautop(
get_post_meta( get_the_ID(), '_always_visible_content', TRUE )
);
}
else
{
// show regular content
}
}
Related Posts:
- Personalized message for each unique password-protected page
- wp_enqueue_script adding conditional statement not working
- Check if first paragraph is an image, then show custom code right after it?
- If post author role is X
- Can a conditional statement apply to part of a slug?
- Add default content to posts in a specific category?
- is_front_page, is_page(‘slug’), is_page(id) not working
- Need help on creating If-statement for custom meta fields
- How to make gravatar.com avatars conditional?
- Loading Scripts on Specific Pages
- Condition function for is parent category?
- Conditional Statement – Best Way to Remove Nav on Contact Page
- Proper syntax for simple conditional bloginfo language
- wordpress is_page() problem
- Location-Based Content
- Conditional Shortcode image display
- Change Woocommerce order button page on particular page
- Change a url / link if a user is logged in?
- to create own conditional tags for business directory in wp
- How to use “Cases” instead of “IFs” for conditional logic
- Which is the better way to write a conditional statement? [closed]
- Nested conditionals
- if/Else have_posts Else fails to echo message to page
- Conditonal statement for iPad
- Return function only on certain pages
- How to write this conditional statement?
- Conditional for Custom Post Types
- Date-Based Conditional Tag
- Message box when accessed from iPad
- Show this code if user has previously left a comment
- Insert a conditional in the middle of a function to give it 2 different outcomes
- How can I use ‘edit_form_after_title’ conditionally?
- Force Log in to view a page
- Conditional loading of CSS for my plugin
- Looks like this if condition is not working [closed]
- Generating images from an array of categories
- WP conditional site logo and header block
- How to know if the most recent article
- Widget logic conditional widget
- How to display image on condition that a selection has been made
- How to Conditionally Not Display a Link Based on Current URL?
- Allow users to only CREATE one single (custom) post
- If statement to check for post_content
- why is my custom loop failing?
- Conditional sidebar menu
- What is the best way to disable my WP website if the user has adblocker on? [closed]
- check if post is set to “password protected”
- Disable user registration password email
- Replacing the WordPress password validation
- how to create a conditional content_width for a wordpress theme?
- How can I change the default wordpress password hashing system to something custom?
- Conditional to test if post has password protection enabled
- How to disable Woocommerce password recovery and use the default WordPress password reset page?
- Migrating users from .com to .org?
- User defined password at registration – registration email sends auto generated pass
- Shortcode to Gutenberg-block: additional text on front-end and conditional display
- Redirect a password protected page?
- Multiple Password Portal Page BEFORE User Account Set Up
- Trying to use Ternary operators with WP Conditionals
- Can user_register output the password?
- Why is resetting the WordPress Users password not working?
- Password protect a specific category page/post
- How to filter/hook-into retrieve_password() to filter $_POST[‘user_login’]?
- Preventing BFA in WordPress without using a plugin
- Conditional custom field query
- Force user to change their password on first log in of site using shortcode
- Conditionally hide or show woocommerce product variation in fontend by custom field
- How do I toggle pagination on/off in search results and category listings via a link?
- Password protect pages – allow more than one password
- How to show different sub sites based on Member’s user name In word press?
- Basic password protection without using users and roles
- How to check if the current page is at a specified path in the URL?
- What is the CODEX intercept for wp-login.php?action=lostpassword
- Only on single post page
- How to make widget appear conditionally
- How can i login with user’s password in WordPress being an admin?
- Password protect a custom template
- lostpassword_redirect filter is not used
- Password recovery URL has error – but not found in code or db
- Put password on a wordpress link in a article
- WP Admin Login keeps redirecting to login
- include content within conditional statement?
- Using password protection to load different page elements?
- Custom wp_query inside a conditional stament inside a template part doesn’t work: why?
- Automatically change the page password for more than one page
- Forgot password flow does not work, getting email with a link but after clicking link it’s not working
- Problem with login / reset password links in users emails
- My Password Protected Pages Aren’t Working
- Use content filter on the post that is password-protected
- Change wp-login.php? Problem with .htaccess password protection and multi user shop
- pull data from wordpress database
- Conditional statement: if is_category, append at the end of page
- User login without username, only password
- If else statement based on referral URL
- Whats a good strategy for localising WordPress post and page content?
- Conditional statements based on custom meta value in category archives
- How to store a plain password in WordPress database in another field
- Not able to see the error [closed]
- Can a wordpress admin see my failed Login attempts?
- Conditional display based on ACF checkbox