display metabox with array

<?php
$my_query = new WP_Query(‘post_type=listing&posts_per_page=-1’);

/* bathrooms */
$bathrooms=array();
while ($my_query->have_posts()) : $my_query->the_post();
$bathrooms_val =  get_post_meta($post->ID, “_listingpress_bathrooms”,true);
if(!empty($bathrooms_val))
{
$bathrooms[]=$bathrooms_val;
}
endwhile;  wp_reset_query();

$final_bathrooms= array_unique($bathrooms,SORT_REGULAR);

sort($final_bathrooms);
?><select value=””><option>Badroom</option><?php
foreach($final_bathrooms as $bathroom)
{
?><option value=”<?php $bathroom; ?>”><?php echo $bathroom; ?></option><?php
}
?></select>

Advertisements

Tagged: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: