Support

Account

Home Forums General Issues get_field() gets data for some records but not others

Solving

get_field() gets data for some records but not others

  • I find this very strange behavior but for some records get_field() works but for others not.

    I have a very simple line of code as follows;

    $result = get_field(‘field_64b3a27f9a070’); // name
    echo $result;
    $theID = get_post()->ID;
    echo $theID;

    When I navigate to one custom post, it displays the name, as expected, along with the custom post ID. When I go to another custom post, it doesn’t display the name even though it is present. It displays the post ID as expected.

    The name field lives under field_64b38c4e3ec56 which is a GROUP.

    Any help appreciated.

  • Hey! I noticed you’re encountering an intriguing issue with get_field – it’s grabbing the post ID consistently, but the name field from a group isn’t displaying consistently. Firstly, double-check that the field key (‘field_64b3a27f9a070’) is spot on for the name field in the group (‘field_64b38c4e3ec56’). Ensure the name field is populated for the post where it’s not showing. If the problem persists, consider debugging with var_dump to dive into the function’s output. Let’s iron out these kinks together! 👊

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

You must be logged in to reply to this topic.