Home Forums General Issues get_field() is empty in WP_Query inside Gutenberg block


get_field() is empty in WP_Query inside Gutenberg block

  • Hi,

    I have a WordPress template based on Sage which is using the new ACF blocks feature and Blade templates. Everything is working just fine.

    I have a Gutenberg block that pulls some posts with WP_Query then loops through them this way:

    $projects = new WP_Query(…);
    while ($projects->have_posts()): $projects->the_post();
        the_title(); // works
        the_ID() // works
        the_field('location') // does not work
        the_field('location', get_the_ID()); // works

    Do you have any idea why the_field() fails without passing an ID even though the_post seems to be set up properly (because the_ID() works correctly)?

    Thanks in advance,

  • No one?

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

You must be logged in to reply to this topic.

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.