Home › Forums › Add-ons › Flexible Content Field › 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:
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>“<?php the_field('quote_text')?>”</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 🙂
You must be logged in to reply to this topic.
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!
Plugin boilerplates can do some of the heavy lifting during initial development. We look at four options to speed up your plugin creation. https://t.co/ZtMsdBxAHw
— Advanced Custom Fields (@wp_acf) June 5, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.