我正在使用 taxonomy-images/ WordPress 插件 ( https://en-gb.wordpress.org/plugins/taxonomy-images/ )
目标:我有一个海报分类,我想显示术语名称和术语图像。我希望能够显示、检索我的分类中的所有术语,无论术语名称是否为空。
问题:但如果两个数据都没有输入,我将无法显示该术语。我无法正确使用“hide_empty”。
任何帮助表示赞赏。谢谢
<?php
/*
Template Name: gof Poster Home Page */
// https://en-gb.wordpress.org/plugins/taxonomy-images/
?>
<?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="poster-cat-wrapper">';
foreach ( $terms as $term ) {
$term_list .=
'<div class="poster-cat">' .
'<a href="/posters/?gof=' . $term->name . '">' .
wp_get_attachment_image( $term->$images, 'detail' ) .
'<p>' . $term->name . '</p>' .
'</a>' .
'</div>';
$i++;
// '<a href="/posters/?gof=' . $term->name . '">' . $term->name . '</a>'
if ( $count != $i ) {
$term_list .= ' ';
}
else {
$term_list .= '</div>';
}
}
}
?>