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

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 made one custome post in that there is one custom field call _as_roomname.

I create total 5 custom post and I want to retrive all it's name but I get only first value.

function postlogo(){
global $post;
$counting = 1;
$count = 1;
$args = array( 'post_type' => 'casino', 'posts_per_page' => 5 );
$rPosts = new WP_Query($args);

while ($rPosts->have_posts()) : $rPosts->the_post();?>
<h1><?php echo get_post_meta(get_the_id(), '_as_roomname', true);?> Review </h1><?php
$count = $count + 1;    


Casino.com Review
Casino.com Review
Casino.com Review
Casino.com Review
Casino.com Review

I want this unique name from all post but it give me only first value. How will I get that I don't know.

share|improve this question

You have the parameter of get_post_meta set to true which returns single result, set it to false or remove it completely.

 $dump_array = get_post_meta(get_the_id(), '_as_roomname')
 //check whats in the array

// or loop for output
foreach( $dump_array as $dump )
echo $dump;
share|improve this answer
Thanks for your replay I had tried that but it's give the same Output – wasim kazi Apr 15 '13 at 13:35
Setting it to false or empty returns an array, so you have to loop over it for output most likely using foreach, I edited my answer. – Wyck Apr 15 '13 at 13:38
it's also not working. Now it show blank array. array(0) { } – wasim kazi Apr 15 '13 at 13:54
Then is must be a another problem, if the array is empty, it's empty. – Wyck Apr 15 '13 at 14:02

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.