Home › Forums › General Issues › Hide ACF if password protected › Reply To: Hide ACF if password protected
Solution:
Note that there’s an IF and an ENDIF which need to be wrapped around the ACF fields.
Also note that the default WP the_content() code must remain in place — even if you’re not using it for content in your template.
<div class="entry-content clearfix">
<!-- HIDES ACF FIELDS for use with WP password protect feature -->
<?php if( !post_password_required( $post )): ?>
<h2><?php the_field( 'business_name' ); ?></h2>
<p><?php the_field( 'client_name' ); ?></p>
<p><small><?php the_field( 'date' ); ?></small></p>
<h1><?php the_field( 'introduction_title' ); ?></h1>
<p><?php the_field( 'introduction_text' ); ?></p>
<!-- ENDS HIDE ACF FIELDS with WP Password Protect -->
<?php endif; ?>
<?php the_content(); ?>
</div><!-- .entry-content -->
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.