Support

Account

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 -->