Home Forums General Issues the_field not returning values


the_field not returning values

  • I’ve created a cpt and I’ve used acf to attach fields to it.

    I’m creating a loop to get publish the cpt’s. Within my loop neither ‘the_field()’ nor ‘echo the_field() are returning values.

    What do I need to do in order to print the values from my fields?

    This is what my loop looks like:
    In this loop, values are returned as expected for the_title and get_permalink.

    <?php while ($jobs_query->have_posts()) : $jobs_query->the_post(); ?>
    <article class=””>

    <h3 class=”job-title”><?php the_title() ?></h3>

    <div class=”job-description”>
    <?php echo the_field(‘job_description’) ?>

    <p class=”job-readmore”>“>read more</p>

    <?php endwhile; ?>

  • the_field() echos, get_field() returns. Use either the_field() or echo get_field()

    However, that aside, there’s nothing in the code you’ve supplied that indicates what could be wrong.

    Is the_title() outputting the correct post title?

    The only two conclusions I can reach based on the code above is that the field name is not “job_description” or the field has no value.

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

You must be logged in to reply to this topic.