I am using the Advanced Custom Fields plugin and want to read the value of the custom fields. For dropdown and text fields, this is straightforward as the value is kept in plain text, so the get_post_custom_values functions works.

For multi-select field, however, ACF keeps data like this:


So the sensible thing to do is to use the get_value function from ACF to read the value and parse it into objects.

In the ACF plugin, the first line does:

$acf = new Acf();

So I assumed I could just use the $acf variable in my plugin and do:

$afc->get_value ($post_id, $key);

but received error with

PHP Notice:  Undefined variable

I am new to php development so I might not have understood the scoping rule correctly. So, what's the right way to do this and what am I doing wrong?

1 Answer 1


The multi-select field you referenced appears to be stored in PHP serialized format, which is used for "storing or passing PHP values around without losing their type and structure".

To unserialize a custom field value you need to use the unserialize() function:

$multi_select_field = unserialize( get_post_meta( get_the_ID(), 'custom_field_key', true ) );
  • Thanks for your answer, I will try out this approach. However, I would still like to know how I can call a function from another plugin.
    – ltfishie
    Mar 14, 2012 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.