Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a post_meta "thevoters" that store users ids like: 1,2,20 ...etc, How i can turn this id's to User Names to list them in a single page?

This will echo the numbers as text,

echo get_post_meta(get_the_ID(), "thevoters", true);

any help?
thanks a lot!

share|improve this question

1 Answer 1

up vote 2 down vote accepted
$thevoters_ids = get_post_meta( get_the_ID(), "thevoters", true ); // get a comma separated list of ids

$thevoters_ids = explode( ',', $thevoters_ids ); // turn the list into an array

foreach ( $thevoters_ids as $thevoter_id ) { // loop through the ids
    $thevoter = get_user_by( 'id', $thevoter_id ); // get the user object by id
    echo $thevoter->display_name; // display the user name
share|improve this answer
thanks a lot @sorich87! – Philip Jan 23 '11 at 10:19
You are welcome. – sorich87 Jan 23 '11 at 10:51

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.