Forums

Retrieving the value of a custom meta dropdown box for use in custom columns (3 posts)

  1. eritt
    Member
    Posted 9 months ago #

    Hello,

    I have some custom meta boxes in a custom post type, and I am creating some custom columns for them in the add/edit screen of the custom post type.

    I can retrieve the values of a text box just fine in my manage_posts_custom_column action, using a switch case like:
    case "my_field":
    $custom = get_post_custom();
    echo $custom["my_field"][0];
    break;
    etc.......
    But When I try to retrieve the values of a dropdown/select box, it looks weird. It shows the value but it is prefixed by:
    a:1:{i:0;s:4:"
    and followed by:
    ";}

    So, how do I properly retrieve the values of dropdown box? I can't find an example anywhere...

  2. keesiemeijer
    moderator
    Posted 9 months ago #

    This looks like a serialized array, try to unserialize it.

  3. eritt
    Member
    Posted 9 months ago #

    thank you. That was all I needed to help me research it....

    This works!:
    case "my_field":
    $customdropbox = get_post_custom_values('my_field');
    $customdropbox = unserialize($customdropbox[0]);
    echo current($customdropbox);
    break;

Reply

You must log in to post.

About this Topic