
There are a few filters that you can use in your theme to display the image associations created by this plugin. Please read below for detailed information.
The following filter will display the image associated with the term asked for in the query string of the URL. This filter only works in views that naturally use templates like category.php, tag.php, taxonomy.php and all of their derivatives. Please read about template hierarchy for more information about these templates. The simplest use of this filter looks like:
print apply_filters( 'taxonomy-images-queried-term-image', '' );
This code will generate and print an image tag. It’s output can be modifed by passing an optional third parameter to apply_filters(). This parameter is an array and the following keys may be set:
after (string) – Text to append to the image’s HTML.
attr (array) – Key / value pairs representing the attributes of the img tag. Available options include: alt, class, src and title. This array will be passed as the fourth parameter to WordPress core function wp_get_attachment_image() without modification.
before (string) – Text to prepend to the image’s HTML.
image_size (string) – May be any image size registered with WordPress. If no image size is specified, ‘thumbnail’ will be used as a default value. In the event that an unregistered size is specified, this filter will return an empty string.
Here’s an example of what a fully customized version of this filter might look like:
print apply_filters( 'taxonomy-images-queried-term-image', '', array( 'attr' => array( 'alt' => 'Custom alternative text', 'class' => 'my-class-list bunnies turtles', 'src' => 'this-is-where-the-image-lives.png', 'title' => 'Custom Title', ), 'before' => '<div id="my-custom-div">', 'after' => '</div>', 'image_size' => 'medium' ) );
If you just need to get the database ID for the image, you may want to use:
$image_id = apply_filters( 'taxonomy-images-queried-term-image-id', 0 );
If you need to get the full object of the image, you may want to use:
$image = apply_filters( 'taxonomy-images-queried-term-image-object', '' );
If you need to get the URL to the image, you may want to use the following:
$image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '' );
You can specify the size of the image in an option third parameter:
$image_url = apply_filters( 'taxonomy-images-queried-term-image-url', '', array( 'image_size' => 'medium' ) );
If you need data about the image, you may want to use:
$image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '' );
You can specify the size of the image in an option third parameter:
$image_data = apply_filters( 'taxonomy-images-queried-term-image-data', '', array( 'image_size' => 'medium' ) );
When a post is being displayed you may want to display the images associated with all of the terms associated with the post. The taxonomy-images-list-the-terms filter does this. Here’s what it looks like in its simplest form:
print apply_filters( 'taxonomy-images-list-the-terms', '' );
This filter accepts an optional third parameter that you can use to customize its output. It is an array which recognizes the following keys:
after (string) – Text to append to the output. Default value is a closing unordered list tag.
after_image (string) – Text to append to each image. Default value is a closing list-item tag.
before (string) – Text to prepend to the output. Default value is an open unordered list tag with an class attribute of “taxonomy-images-the-terms”.
before_image (string) – Text to prepend to each image. Default value is an open list-item tag.
image_size (string) – Any registered image size. Values will vary from installation to installation. Image sizes defined in core include: “thumbnail”, “medium” and “large”. “full” may also be used to get the unmodified image that was uploaded. Defaults to “thumbnail”.
post_id (int) – The post to retrieve terms from. Defaults to the ID property of the global $post object.
taxonomy (string) – Name of a registered taxonomy to return terms from. Defaults to category.
Here’s an example of what a fully customized version of this filter might look like:
print apply_filters( 'taxonomy-images-list-the-terms', '', array( 'before' => '<div class="my-custom-class-name">', 'after' => '</div>', 'before_image' => '<span>', 'after_image' => '</span>', 'image_size' => 'detail', 'post_id' => 1234, 'taxonomy' => 'post_tag', ) );
You will want to use the taxonomy-images-get-terms filter. This filter is basically a wrapper for WordPress core function get_terms(). It will return an array of enhanced term objects: each term object will have a custom property named image_id which is an integer representing the database ID of the image associated with the term. This filter can be used to create custom lists of terms. Here’s what it’s default useage looks like:
$terms = apply_filters( 'taxonomy-images-get-terms', '' );
Here is what php’s print_r() function may return:
Array ( [0] => stdClass Object ( [term_id] => 8 [name] => Pirate [slug] => pirate [term_group] => 0 [term_taxonomy_id] => 8 [taxonomy] => category [description] => Pirates live in the ocean and ride around on boats. [parent] => 0 [count] => 1 [image_id] => 44 ) )
As you can see, all of the goodness of get_terms() is there with an added bonus: the image_id parameter!
This filter recognizes an optional third parameter which is an array of arguments that can be used to modify its output:
cache_images (bool) If this value is true all associated images will be queried and cached for later use in various template tags. If it is set to false, this query will be suppressed. Do not set this value to false unless you have a really good reason for doing so 🙂 Default value is true.
having_images (bool) If this value is true then only terms that have associated images will be returned. Setting it to false will return all terms. Default value is true.
taxonomy (string) Name of a registered taxonomy to return terms from. Multiple taxonomies may be specified by separating each name by a comma. Defaults to category.
term_args (array) Arguments to pass to get_terms() as the second parameter. Default value is an empty array.
Here’s an example of a simple custom loop that you can use to display all term images:
$terms = apply_filters( 'taxonomy-images-get-terms', '' ); if ( ! empty( $terms ) ) { print '<ul>'; foreach ( (array) $terms as $term ) { print '<li><a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '">' . wp_get_attachment_image( $term->image_id, 'detail' ) . '</a></li>'; } print '</ul>'; } If you have questions about integrating this plugin into your site, please add a new thread to the WordPress Support Forum. I try to answer these, but I may not always be able to. In the event that I cannot there may be someone else who can help.
Development of this plugin is hosted in a public repository on Github. If you find a bug in this plugin or have a suggestion to make it better, please create a new issue
If you have fallen in love with this plugin and would not be able to sleep without helping out in some way, please see the following list of ways that you can hook it up!:
Rate it! – Use the star tool on the right-hand sidebar of the plugin homepage.
Let me know if it works – Use the Compatibility widget on the plugin homepage to let everyone know that the current version works with your version of WordPress.
Do you Twitter? Help promote by using this shortlink: http://bit.ly/taxonomy-images
Are you a writer? Help promote by writing an article on your website about this plugin.
The original author of this plugin, Michael Fields, released a handful of plugins dealing with taxonomies. Please see his WordPress.org profile for more information.
Starting from $0 per month.
Rating
Reviewers
40 reviews
Tags
Developed By
Michael Fields
Quick & Easy
Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!
Testimonial plugins for Wordpress
Galleries plugins for Wordpress
SEO plugins for Wordpress
Contact Form plugins for Wordpress
Forms plugins for Wordpress
Social Feeds plugins for Wordpress
Social Sharing plugins for Wordpress
Events Calendar plugins for Wordpress
Sliders plugins for Wordpress
Analytics plugins for Wordpress
Reviews plugins for Wordpress
Comments plugins for Wordpress
Portfolio plugins for Wordpress
Maps plugins for Wordpress
Security plugins for Wordpress
Translation plugins for Wordpress
Ads plugins for Wordpress
Video Player plugins for Wordpress
Music Player plugins for Wordpress
Backup plugins for Wordpress
Privacy plugins for Wordpress
Optimize plugins for Wordpress
Chat plugins for Wordpress
Countdown plugins for Wordpress
Email Marketing plugins for Wordpress
Tabs plugins for Wordpress
Membership plugins for Wordpress
popup plugins for Wordpress
SiteMap plugins for Wordpress
Payment plugins for Wordpress
Coming Soon plugins for Wordpress
Ecommerce plugins for Wordpress
Customer Support plugins for Wordpress
Inventory plugins for Wordpress
Video Player plugins for Wordpress
Testimonials plugins for Wordpress
Tabs plugins for Wordpress
Social Sharing plugins for Wordpress
Social Feeds plugins for Wordpress
Slider plugins for Wordpress
Reviews plugins for Wordpress
Portfolio plugins for Wordpress
Membership plugins for Wordpress
Forms plugins for Wordpress
Events Calendar plugins for Wordpress
Contact plugins for Wordpress
Comments plugins for Wordpress
Analytics plugins for Wordpress
Common Ninja Apps
Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.
Show Sitejabber reviews to build trust, strengthen credibility, and help visitors make confident purchase decisions that support higher sales.
Add a countdown timer to your site to highlight upcoming events or launches and encourage timely user action.
Use a scroll progress bar that visually tracks reading on the page, improves navigation, and keeps visitors aware of their position.
Create and customize product catalogs with a catalog widget that organizes items clearly, improves browsing, and helps visitors explore your offerings easily.
Display social proof avatars that show user activity and ratings, build trust instantly, and help visitors feel confident about your credibility.
Show YouTube videos with a YouTube slider that displays clips in a smooth, customizable layout to boost engagement.
Add a no-code music player to your site to stream audio, share playlists, and support multiple formats with easy setup.
Add a no-code audio player to your site and boost engagement with music, podcasts, and voice content effortlessly.
Make it easy for supporters to contribute using PayPal or Stripe by adding a donation button that keeps giving fast, secure, and on site.
Use team members blobs to present your staff in a clear, creative format that builds trust, supports transparency, and strengthens brand credibility.
Encourage interaction with social votes that let visitors like, upvote, and rank content, boosting engagement and guiding better decisions.
Show trust badges that highlight security and reliability, build customer confidence, and help visitors feel safe making purchases on your site.
More plugins
The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!
