rwsite / wp-term-thumbnail-plugin
WP term thumbnail plugin
Package info
github.com/tikhomirov/wp-term-thumbnail-plugin
Type:wordpress-plugin
pkg:composer/rwsite/wp-term-thumbnail-plugin
Requires
None
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-20 09:41:21 UTC
README
Taxonomy Thumbnail
Assign an image to a WordPress taxonomy term and, separately, a default cover for posts assigned to that term.
Requirements
- WordPress 6.3+
- PHP 8.0+
Installation
- Download the plugin from GitHub Releases, or download the
masterZIP for the code documented here if the latest release is older. - Extract it to
wp-content/plugins/wp-term-thumbnail-plugin(without a suffix such as-master). If you manage your WordPress site with Git, you can also add the repository as a submodule at that path. Keep only one copy of the plugin. - Activate Taxonomy Thumbnail under Plugins.
Usage
- Select the taxonomies under Settings → Media → Term Thumbnail Settings. On Multisite, use Network Admin → Settings → Term Thumbnail. The default selection includes publicly queryable taxonomies.
- Open the term editor for a selected taxonomy. Set Taxonomy thumbnail for the term image and Default Post Taxonomy Thumbnail for a cover that its posts can inherit. The two fields are independent.
| Term meta key | Value |
|---|---|
term_image_id |
Attachment ID of the term's own thumbnail |
default_cover |
Attachment ID of the term's default post cover |
PHP API
Call these helpers after the plugin has loaded:
$image_id = get_term_thumbnail_id($term_id); $image_url = $image_id ? wp_get_attachment_image_url($image_id, 'thumbnail') : false; $cover_id = get_post_default_cover_id($post_id, ['category', 'my_taxonomy']); // On a term archive, display the queried term's thumbnail. the_term_thumbnail(['width' => 100, 'height' => 100]);
get_term_thumbnail_id($term_id)returns the stored ID orfalse.has_term_thumbnail($term_id)checks for a stored ID, not whether the attachment still exists.get_term_thumbnail($args)returns the term image markup (or no image); useterm_idto select a specific term or omit it on a term archive.the_term_thumbnail($args)echoes the result and uses the queried term on taxonomy archives. The result passes through theget_term_thumbnailfilter.get_default_post_thumbnail_id($term_id)returns the term's cover ID ornull.get_default_post_thumbnail($term_id, $args)renders the cover or returns an empty string; withoutthumb_img(), it uses the full-size WordPress attachment image.get_post_default_cover_id($post, $taxonomies)returns the first stored cover ID ornull. It checks the supplied taxonomies in order (default:['category']) and reads terms in the order returned byget_the_terms(). This helper does not check for a featured image or read the plugin's taxonomy settings.
Optional integration
WP Thumbnail Plugin can generate term thumbnails and fallback post covers via thumb_img(), and linked previews in the admin term list via thumb_a_img(). Each function is checked independently. If the corresponding function is unavailable (including installs that only provide kama_thumb_*), attachments are rendered with wp_get_attachment_image().
With thumb_img() available, a term image that cannot be generated can display a placeholder when show_placeholder is enabled (the default). The native WordPress path does not display a placeholder when no attachment is set.
Fallback behavior
- Post covers: The plugin hooks into the
get_post_thumbnailfilter for the enabled taxonomies. It leaves existing markup alone and does not substitute a term cover when the caller suppliedattach_idor the post has a featured-image ID, even if rendering produced no markup. Otherwise, it uses the first term cover that renders, checking enabled taxonomies and then their assigned terms in order. It does not set the post's featured image or hook into WordPress core'spost_thumbnail_htmlfilter. - Rank Math: On singular pages other than the front page, the plugin can fill an empty Facebook or Twitter image list for a post without a featured image. It tries the inherited cover from the configured taxonomies first, then Rank Math's configured default image. It does not replace images Rank Math has already selected.
See the changelog.