Wordpress - How to add images to taxonomies?
Starting from Wordpress 4.4, you can use add_term_meta function to store metadata for a term. This is basically a key-value pair information which is stored in wp_termmeta
table.
Original Answer(Prior to WP 4.4)
Wordpress doesn't have the option to add extra information to taxonomies. There isn't any taxonomy_meta
table. So, you have two options.
- Create a new custom table and save the extra information(image link) there.
- You can also use
options
table to store the information.
You can follow this post of as it shows how to implement what you are trying to do: http://en.bainternet.info/wordpress-taxonomies-extra-fields-the-easy-way/
You can use the Advanced Custom Fields plugin to add a custom field (an image field) to your custom taxonomy group.
WordPress 4.4 introduced Term meta, which means we can now add custom fields to terms just like we do with posts, without hacky code.
Currently though the WP Tax/Term backend UI lacks of an Image selector (and might never have it), but here you'll find a good guide on what was added in WP 4.4
If you won't build your own plugin, then some existing plugins may have already switched to it. I'd advise using a plugin that has already switched to this, e.g. WP Term Images, rather than others that may still use their own DB tables, or worse, WP options tables.