WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom field who's content I would like to output as a ul list.

The custom field contains words that are separated with a spaces between.

I'm trying to use this code here but it's not working.

    $list_items = get_post_meta($post->ID, 'idid');

            $list_items = explode(" ", $list_items) {
                echo '<ul>';
                    foreach($list_items as $list_item)
                        echo '<li>' . $list_item . '</li>';
                echo '</ul>';

share|improve this question
up vote 1 down vote accepted

You are using get_post_meta incorrectly. As you use it, it will return an array - you cannot explode an array. See the codex on get_post_meta();

If you pass true as the third parameter, this tells the function to return a string. So,

$list_items = get_post_meta($post->ID, 'idid', true);

should work.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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