I'm attempting to display a specific taxonomy (channel) in the archive.php page. I want to display the taxonomy's URL, name, post count, and taxonomy image.
This is what I have that's working so far:
<?php
$taxonomy = 'channel';
$tax_terms = get_terms($taxonomy);
$image_url = print apply_filters( 'taxonomy-images-queried-term-image', '' );
?>
<ul>
<?php
foreach ($tax_terms as $tax_term) { ?>
<li>
<?php echo esc_attr(get_term_link($tax_term, $taxonomy)); ?>
<?php echo $tax_term->name; ?>
<?php echo $tax_term->count; ?>
<?php echo $image_url->image_id; ?>
</li>
<?php } ?>
</ul>
I've gotten URL, name and post count working, the part that's not working is the taxonomy image provided by the Taxonomy Images plugin. (in the snippet, it's $image_url)
/
The plugin provides a image_id for an image added to a taxonomy, the plugin has a ton of ways to get the ID and display the image but I just can't seem to find the correct combination to work with my snippet with my level of skill.
Need some help, thanks.
I'm attempting to display a specific taxonomy (channel) in the archive.php page. I want to display the taxonomy's URL, name, post count, and taxonomy image.
This is what I have that's working so far:
<?php
$taxonomy = 'channel';
$tax_terms = get_terms($taxonomy);
$image_url = print apply_filters( 'taxonomy-images-queried-term-image', '' );
?>
<ul>
<?php
foreach ($tax_terms as $tax_term) { ?>
<li>
<?php echo esc_attr(get_term_link($tax_term, $taxonomy)); ?>
<?php echo $tax_term->name; ?>
<?php echo $tax_term->count; ?>
<?php echo $image_url->image_id; ?>
</li>
<?php } ?>
</ul>
I've gotten URL, name and post count working, the part that's not working is the taxonomy image provided by the Taxonomy Images plugin. (in the snippet, it's $image_url)
https://wordpress.org/plugins/taxonomy-images/
The plugin provides a image_id for an image added to a taxonomy, the plugin has a ton of ways to get the ID and display the image but I just can't seem to find the correct combination to work with my snippet with my level of skill.
Need some help, thanks.
Share Improve this question edited Apr 22, 2017 at 18:54 Chozen asked Apr 22, 2017 at 14:13 ChozenChozen 1632 gold badges8 silver badges24 bronze badges2 Answers
Reset to default 0Don´t know how this plugin works in detail but i would try this:
<?php
$taxonomy = 'channel';
$tax_terms = get_terms($taxonomy);
?>
<ul>
<?php
foreach ($tax_terms as $tax_term) { ?>
<li>
<?php echo esc_attr(get_term_link($tax_term, $taxonomy)); ?>
<?php echo $tax_term->name; ?>
<?php echo $tax_term->count; ?>
<?php print apply_filters( 'taxonomy-images-queried-term-image', '' ); ?>
</li>
<?php } ?>
</ul>
Figured out a better option.
Instead of using Taxonomy Images plugin, Instead, I opted to use the more widely used Categories Images plugin.
https://wordpress.org/plugins/categories-images/
The working code below:
<?php
$taxonomy = 'channel';
$tax_terms = get_terms($taxonomy);
foreach ($tax_terms as $tax_term) { ?>
<div class="column">
<?php echo esc_attr(get_term_link($tax_term, $taxonomy)); ?>
<?php echo $tax_term->name; ?>
<?php echo $tax_term->count; ?>
<?php echo z_taxonomy_image_url($tax_term->term_id); ?>
</div>
<?php } ?>