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