我正在使用taxonomy-images / WordPress插件(https://en-gb.wordpress.org/plugins/taxonomy-images/)
目标:我有一个海报分类法,我想显示术语名称和术语图像 . 我希望能够显示,检索我的分类中的所有术语,无论术语名称是否为空 .
问题:但如果两个数据都没有输入,我就无法显示该术语 . 我无法正确使用'hide_empty' .
任何帮助赞赏 . 谢谢
<?PHP
/ *
模板名称:gof Poster主页
<?PHP
$ taxonomy = 'month-category';
$ orderby = 'name';
$ order = 'ASC';
$ show_count = false;
$ pad_counts = false;
$ hierarchical = true;
$ hide_empty = false;
$ title ='';
$ images = 'image_id';
$ args = array(
'taxonomy' => $ taxonomy,
'orderby' => $ orderby,
'order' => $ order,
'show_count' => $ show_count,
'pad_counts' => $ pad_counts,
'hierarchical' => $ hierarchical,
'hide_empty' => $ hide_empty,
'title_li' => $ title
);
// $ terms = get_terms('month-category',$ args);
// $ terms = apply_filters('taxonomy-images-get-terms','month-category',$ args);
$ terms = apply_filters('taxonomy-images-get-terms','',$ args);
if(!empty($ terms)&&!is_wp_error($ terms)){
$ count = count($ terms);
$ i = 0;
$ term_list = '<div id= _559148_ >';
foreach($ terms as $ term){
$ term_list . =
'<div class= _559150_ >' .
'<a href= _559152_ >' .
wp_get_attachment_image($ term - > $ images,'detail') .
'<p>' . $ term-> name . '</p>' .
'</a>' .
'</div>';
$ i;
// '<a href= _559159_ >' $ term-> name . '</a>';
if($ count!= $ i){
$ term_list . = ' ';
}
其他{
$ term_list . = '</div>';
}
}
}
?>
1 回答
我也无法弄清楚如何做到这一点,但我发现了一个讨厌的黑客 . 在'/ plugins / taxonomy-images /'中的'public-filters.php'中查找此部分:
把它改成这个:
再一次:知道这不是正确的解决方案!您应该编写一个过滤器来为您执行此操作 . 每个插件更新都会破坏此功能 .