Hi there,
I’m struggling to display a simple text field into a loop. Please find below my code :
<?php
$args = array(
'post_type' => 'realisations',
'posts_per_page' => 99
);
$the_query = new WP_Query( $args );?>
<div class="last-post-type portfolio-grid">
<?php
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="card item">
<div class="card_wrapper">
<div class="card_thumbnail">
<?php the_post_thumbnail('full'); ?>
</div>
<div class="card_content">
<h3><?php the_title(); ?></h3>
<h5><?php the_field('realisation_sub'); ?>h</h5>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif;?>
<?php
// Restore original Post Data
wp_reset_postdata(); ?>
</div>
the ‘realisation_sub’ field remains empty and I can’t figure out why.
Thanks by advance for your help.
J
Ok, I found my mistake. If it could be useful to someone, don not forget to add , get_the_ID()
to make it work.
like so in my exemple
<h5><?php the_field('realisation_sub'); ?>h</h5>
🙂