WordPress taxonomy images plugin displaying all terms
I am using taxonomy-images/ WordPress plugin (https://en-gb.wordpress.org/plugins/taxonomy-images/)
Target: I have got a poster taxonomy and I would like to display term name and term image. I would like to be able to display, retrieve ALL terms in my taxonomy, no matter term name is empty.
Issue: But if both data are not entered I can not display the term. I am not managing to correctly make use of 'hide_empty'.
Any help appreciated. Thanks
<?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>';
}
}
}
?>
I cannot figure out how to do this either, but I found a nasty hack. Look for this part in 'public-filters.php' in '/plugins/taxonomy-images/':
$args = wp_parse_args( $args, array(
'cache_images' => true,
'having_images' => true,
'taxonomy' => 'category',
'term_args' => array('hide_empty' => false),
) );
Change it to this:
$args = wp_parse_args( $args, array(
'cache_images' => true,
'having_images' => true,
'taxonomy' => 'category',
'term_args' => array('hide_empty' => false),
) );
Once again: Know that this is NOT the right solution! You should write a filter that does this for you. Every plugin update will break this functionality.
链接地址: http://www.djcxy.com/p/69354.html