问题描述
我正在从事房地产项目,需要获得特定分类法的条款。我的意思是其所在州的城市属性。 这是我编写的代码:
RespawnManager
我需要列出州立城市的属性,如何更改这些代码?
解决方法
我自己找到了答案,我想列出具有特定状态的特定状态的属性。 例如状态为(租金)的喀布尔州的属性,以及该州每个城市的属性。
<?php $terms = get_terms("property-city");
foreach($terms as $term)
{
$items = get_posts(array(
'numberposts' => -1,'post_type' => 'property','post_status' => 'publish','tax_query' => array(
'relation' => 'AND',array(
'taxonomy' => 'property-city','field' => 'slug','terms' => $term->slug
),array(
'taxonomy' => 'property-state','field' => 'name','terms' => 'هرات','operator' => 'NOT IN'
),)
));
$count = count( $items );
?>
<ul>
<li>
<a href="<?php echo get_term_link($term);?>" <?php if ($count == 0) echo " style='display: none';"; ?>>
<?php echo $term->name. ' ('. $count .')';?>
</a>
</li>
</ul>
<?php
}
?>