选择带有值计数的选项元数据箱

时间:2014-10-22 08:08:25

标签: php wordpress count meta-boxes

我早期使用wordpress和php代码。

所以,我有类型(公寓,住宅,别墅等)的邮政类型属性。例如,对于类型公寓任何三个属性。但在选择选项上,如下所示:

- 类型

-Apartment

-Apartment

-Apartment。

所以,我想这样:

- 类型

-Apartment(3)

但是,我使用计数。不适合我。

所以,这是我的代码:

$args = array(
'post_type' => 'property',
'posts_per_page'    => -1
);
$property = get_posts($args);

这是我的代码选择选项。

<select name="type">
<option>Type</option>
<?php  foreach( $property as $homes ) {
$type = get_post_meta($homes->ID, 'type', true);
if ( $type == '---') continue;
$new_type = count($type);
echo '<option value="'.$homes->ID.'">'.$new_type.'</option>';
 } ?>
</select>
谁能帮帮我?提前致谢。问候

0 个答案:

没有答案