Support

Account

Home Forums General Issues Get the meta_id of an acf

Solved

Get the meta_id of an acf

  • Is there a way to get the meta_key of an field using the standard acf functions?

    I know I could do a custom db query but that seems unnecessarily complex for such a simple task.

    Thanks
    A.

  • Do you mean the Field Key?

    If so you could use
    get_field_object instead of the normal get_field.

    For example, this will display all related information from our field:

    <?php $myfieldname = get_field_object(myfieldname); ?>
    <pre><?php print_r($myfieldname) ?></pre>

    And this will display the Field Key from the above:
    <?php echo $text[key]; ?>

    We can skip all the above and do it in one line, on it’s own like this:
    <?php echo get_field_object('text')[key]; ?>

  • Nope, I was looking for an unique key for every row of my repeater field. I had the hope that I could use the actual meta_id key from the db but I realized that this key changes with every update of the post .. so that’s not an option.

    I’m now working on a custom field type that fills in an auto generated key.

  • Oh I see, a unique identifier. That does sound like a bespoke field type is the best bet.

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

The topic ‘Get the meta_id of an acf’ is closed to new replies.