我使用数组格式的分类法显示区域名称,每个分类法都有不同的区域名称和帖子。当我单击区域名称时,它应该从所有分类中拉出所有帖子,但我的问题是区域名称重复,所以我只想隐藏重复的区域名称。有谁能指导我解决这个问题吗。
Here is my Code :
<div id="footer">
<h1>Area Names </h1>
<?php
$taxonomyArray = array("health_area","schools_area","office_area","salonsandsaps_area");
for($Inc=0;$Inc<count($taxonomyArray);$Inc++){
$orderby = \'name\';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = \'\';
$empty = 0;
$args = array(
\'taxonomy\' => $taxonomyArray[$Inc],
\'orderby\' => $orderby,
\'show_count\' => $show_count,
\'pad_counts\' => $pad_counts,
\'hierarchical\' => $hierarchical,
\'title_li\' => $title,
\'hide_empty\' => $empty
);
wp_list_categories( $args );
}
?>
</ul>
</div>
Here is Screenshot of result
提前谢谢。
Screenshot of result after updating code :
SO网友:Ranuka
我没有测试代码。但这应该是工作。
<div id="footer">
<h1>Area Names </h1>
<?php
$taxonomyArray = array("health_area","schools_area","office_area","salonsandsaps_area");
$temp_array=array();
for($Inc=0;$Inc<count($taxonomyArray);$Inc++){
$orderby = \'name\';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = \'\';
$empty = 0;
if($Inc!=0)
{
$temp_array=array_merge($temp_array,get_categories($args));
}
$args = array(
\'taxonomy\' => $taxonomyArray[$Inc],
\'orderby\' => $orderby,
\'show_count\' => $show_count,
\'pad_counts\' => $pad_counts,
\'hierarchical\' => $hierarchical,
\'title_li\' => $title,
\'hide_empty\' => $empty,
\'exclude\' =>$temp_array
);
wp_list_categories( $args );
}
?>
</ul>
</div>