Support

Account

Home Forums ACF PRO Subfield in a loop not displaying

Unread

Subfield in a loop not displaying

  • I’m displaying a loop of custom post type. The custom fields are displaying correctly, however I can’t get the subfields to display.

    In this case I’ve created a custom field named project_description with a subfield called sub_heading within a group called Project Page.

    This is what I’ve done so far. Can anyone tell me what I’m doing wrong?

    <section class="services-section">    
                      <div class="container services-section-container">
                         <h1 class="fp-header extended-black-l">Featured Projects</h1>  
                         
                         <?php 
                          $featuredProjectSection = new WP_Query(array(
                            'posts_per_page' => 10,
                            'post_type' => 'project'
                          ));
    
                          while($featuredProjectSection->have_posts()) {
                          $featuredProjectSection->the_post(); $i++; if(($i % 2) == 0) { ?>
                       
                            <div class="row splitcontent-services">
                              <div class="col-lg-6 col-6 services-img-left">
                                <img src="<?php the_field('top_image') ?>">
                                             
                              </div>
                              
                              
                              <div class="col-lg-6 col-6 services-content-right">                         
                                <h2 class="condensed-semibold-l"><?php the_title(); ?></h2>
                                  <?php if( have_rows('project_description') ): ?>
                                  <?php while ( have_rows('project_description') ) : the_row(); 
                                   $subhead = get_sub_field('sub_heading');?>                             
                                <h3 class="regular-m"><?php echo $subhead; ?></h3>
                                <?php endwhile; ?>
                                <?php endif; ?>
    
                                <button class="extended-black-s"><a href="<?php the_permalink(); ?>">Learn More ></a></button>
                                	
                              </div> 
                            </div>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.