There’s a great plugin called Taxonomy Images. It lets you set one image per category that you can then access in all sorts of ways.
It’s a little funky in that it uses some custom filters to return the images, but the documentation is pretty good and you should be able to figure it out.
== UPDATE ==
Here’s a quick example that gets the image based on ID (I’m assuming you’ll have the $category
object that you already have in your snippet:
$images = get_option('taxonomy_image_plugin');
$cat_id = $category->term_taxonomy_id;
if( array_key_exists( $cat_id, $images ) ) {
echo wp_get_attachment_image( $images[$cat_id] );
}
Here’s a slightly expanded version of that code on the support forums.
Related Posts:
- Custom Nav Walker menu – Display category count
- Admin Panel – Disable Moving Selected Terms To Top of Metabox
- Assign different category colours to different categories in the main menu
- Render Selected Categories in Admin Edit Post Screen differently
- Why does the argument list_only do on Walker_Category_Checklist::start_el?
- Create menu / submenu from category subcategory and posts
- Custom Walker for wp_list_categories
- Hooking to walker_nav_menu_start_el to insert list of subpages
- How to modify the output of wp_terms_checklist when used within the built-in category metabox on edit posts?
- wp_list_categories walker without links on categories that have subcategories (to make a nested dropdown menu)
- How to get selected taxonomy or category ID if using custom walker?
- Check is category parent with ids from the childs – get_term_children
- wp_dropdown_categories() show elements checkbox
- How to remove an item from a custom Walker_Nav_Menu
- How to get the term id inside the start lvl method of category walker?
- get_category_children/ the new get_term_children not work
- How would I get a taxonomy/category list inside a Gutenberg block?
- Rewrite rule page url with category
- WP_Query not looking at child category
- Deleting default category in wordpress
- Excluding posts from a category but only if they’re not in multiple categories
- Most recent post from every category/taxonomy but sorted by date
- Showing all the posts in one page?
- How to order categories in Woocommerce that are spread over multiple pages? [closed]
- Script to duplicate categories as tags
- Check if post belongs to any category
- How to sort categories by id in wordpress admin
- How to override Category rendering mechanism
- Can paginate_links() be customized for a specific category or tag?
- Add Product categories to WordPress menu without losing hierarchy
- Custom page for WooCommerce’s /product-category/
- Add Class While on Current Post; wp_list_categories
- get all sub categories without specify any category
- How to use wp_category_checklist()?
- Display child categories in WooCommerce
- Specifying multiple categories in URL (permalink)?
- Check child/parent categories if exists
- WordPress Genesis not excluding category from blog
- How to show only one category in breadcrumb navigation
- Trying to only display 1 category using get_posts
- How to display singular form of category name?
- Select posts by name and category per REST API
- Categories for each brands
- Custom User-Created RSS Feed
- How to create a page which lists all categories with its ratings [closed]
- Permalinks: display just one kind of wp category in the posts url
- Get value of custom field in category admin
- How do I make the category sidebar widget (stock) display the total # of posts including those in subcategories?
- Woo Framework: woo_cat_featured not populating
- Show category name, and last 5 post titles below category name?
- get_post_meta not working on category.php
- How can I improve this taxonomy treating approach?
- How to show more than 5 posts of the category?
- Dropdown Categories used in form shows no results when all is selected
- Redirect Changed Permalink on wordpress
- Grandchild Term Things Grandfather Term is It’s Parent
- get full category structure by post id
- Home Page Template – Specific Category
- Same menu for different taxonomies to reach different content
- Using categories with pages
- Show next post in same category but start from the latest
- List all posts of certain category which share some tags
- Search form options group categories
- Natural sort / ordering wp_dropdown_categories
- Make wp_dropdown_categories into a variable that persists until changed?
- show category in woocommerce
- Can I define multiple paginations on a single page?
- Echo Category Nicename
- Category sticky latest
- How can I exclude a category from the main loop with the category name & not ID?
- Explode() expects a string
- how to remove alphabetical order of category in WordPress?
- How to show only the last two categories in a menu?
- How can i add service category here? [duplicate]
- How to exit out of delete_categories and stop action?
- Meta Query | Compare category name and meta value
- How to filter tags by category?
- Programmatically Create Category and sub Category and sub sub Category
- How Can I Display the Category Description in a Theme with no Category.php or Archive.php?
- WooCommerce – Get products from category right before deleting category
- omit categories from main navigation menu
- How to test if the post is in a primary category
- Most efficient way to display current post subcategories?
- How to relocate images
- Category next page link not working
- How to display the past events in one of the category?
- How to Query the Top 5 Posts of a specific category?
- Page Type with Category Link
- Using wp_list_pages to create 2 lists of pages and include and exclude some of them depending on their category
- How to create default categories in new installs?
- If I change the taxonomy of a post will it get a new time stamp?
- Check if value is a custom taxonomy category name
- Tracking multiple tags or categories
- 2 loops in archive.php (one for each category)
- How to load jquery tag-it plugin into admin?
- not empty categories don’t show in menu [closed]
- How do I add and display a custom image field to a category? [duplicate]
- Category pagination not working in category.php please help me
- Print the associated categories of the current post starting with parent (with option to remove href)
- Add category image before post title on homepage