Home Forums General Issues get_fields($id) returns false


get_fields($id) returns false

  • I’ve created a custom post type and attached custom fields to it.

    I’ve created an instance of the CPT, and added custom data to it.

    I’ve also created a php template for presenting the data.

    I have this:

    $id = get_the_id();
    $fields = get_fields($id)

    If I var_dump the id, the id for the post shows as expected.
    If I var_dump $fields, then I get “bool(false)”.

    How do I get the custom fields?

  • A bit more information:

    If I do this then I can see the custom field values:
    ` $meta = get_post_meta($id);

    That’s fine, but I’d like to be able to use the ACF functions.

  • Where/When are you calling get_fields()? The only reason that this should be happening is if you are calling the function before ACF has initialized, which should not happen in a theme template file.

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

You must be logged in to reply to this topic.