Support

Account

Home Forums Add-ons Flexible Content Field Flexible Content Fields Not Displaying

Solved

Flexible Content Fields Not Displaying

  • Hi, I’m still new to using ACF and I must be getting something wrong, but I can’t seem to see my mistake(s) on this template. I’m not getting any PHP errors, but it’s just not displaying on the page.

    Hoping someone with more sense than myself can spot what I’m doing wrong.

    Here’s my ACF fields if that helps: ACF Flexible Content Fields

    And here’s my code:

    
    <?php while (have_posts()) : the_post(); ?>
    
    <article id="about">
    
    <section class="wrap">
    <?php get_template_part('templates/page', 'header'); ?>
    <?php get_template_part('templates/content', 'page'); ?><br/>
    </section>
    
    <?php if( have_rows('content-section') ): ?>
    <?php while ( have_rows('content-section') ) : the_row(); ?>
    
    <section>
    
    	<?php if( get_row_layout() == 'banner_title' ): ?>
    
    				<div class="banner">
    
    					<div class="banner-base bg-brand">
    
    					<?php if( get_sub_field('banner_main_title') ): ?>
    						<div class="banner-cap">
    							<h1><?php the_sub_field('banner_main_title') ?></h1>
    							<?php if( get_sub_field('banner_sub') ): ?>
    								<h2><?php the_sub_field('banner-sub') ?></h2>
    							<?php endif; ?>
    							<?php if( get_sub_field('banner_sub_small') ): ?>
    								<h3><?php the_sub_field('banner_sub_small') ?></h3>
    							<?php endif; ?>
    						</div>
    					<?php endif; ?>
    
    					<?php if( get_sub_field('banner_img') ): ?>
    						<?php
    
    							$field = get_sub_field_object('align_img');
    							$value = $field['value'];
    
    						?>
    
    						<?php $image = get_sub_field('banner_img');
    
    							if( !empty($image) ): ?>
    
    						<img class="<?php echo $value; ?>" width="100%" height="690" alt="<?php echo $image['alt']; ?>" src="<?php echo $image['url']; ?>"/>
    
    					<?php endif; ?>
    
    					<?php endif; ?>
    
    					</div>
    				</div>
    	<?php endif; ?>
    
    			
    	<?php if( get_row_layout() == 'section_content' ): ?>
    
    		<?php if( get_sub_field('main_content') ): ?>
    
    				<div class="wrap">
    
    					<?php the_sub_field('main_content') ?>
    
    						<div class="quote">
    							<?php 
    
    							$image = get_field('proPic');
    
    									if( !empty($image) ): ?>
    
    									<img class="img-circle pro-pic" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" width="200" height="200" />
    
    									<?php endif; ?>
    
    							<?php if( get_field('quote_text') ): ?>
    							    <blockquote>
    							        <h2>&ldquo;<?php the_field('quote_text')?>&rdquo;</h2>
    							        <?php if( get_field('cite') ): ?><p>- <?php the_field('cite')?>, <?php if( get_field('connection') ): ?><span><?php the_field('connection')?></span><?php endif; ?></p><?php endif; ?>
    							    </blockquote>
    							<?php endif; ?>
    						</div>
    
    			<?php endif; ?>
    
    				</div>
    
    		<?php endif; ?>
    
    	</section>
    	<?php endwhile; ?>
    <?php endif; ?>
    
    </article>
    <?php endwhile; ?>
    
  • Hi @levdev

    It seems you were using the wrong name:

    <?php if( have_rows('content-section') ): ?>
    <?php while ( have_rows('content-section') ) : the_row(); ?>

    Could you please change it to the following one?

    <?php if( have_rows('content_section') ): ?>
    <?php while ( have_rows('content_section') ) : the_row(); ?>

    Please notice the underscore (content-section and content_section).

    I hope this helps 🙂

  • Ahhh I can’t believe I missed something that simple! haha. Thanks so much James 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Flexible Content Fields Not Displaying’ is closed to new replies.