9

Q: Is it possible to add images to all of my taxonomies (default and custom ones)?

Note: I do not want to use any plugins (not my favourite solution for design related matters).

Usage: I want to create really practical custom post type portfolio with custom taxonomies. For example, custom taxonomy - clients, so if multiple projects from same customer/client would be realted and at the same time I could use the taxonomy as showcase of my clients. The similar usage would go with almost of my taxonomies (whether to have taxonomy archive with image and description on).

Any good practice advice here? Thanks in advance

Clarification: I want to add images to the terms of my custom taxonomies. Example, custom post type 'portfolio' with custom taxonomy 'clients', where each 'client' term (lets say Adidas) would have its logo attached.

  • Can you clarify what you mean, e.g. do you want to add an image to the 'category taxonomy' or do you want to add an image to 'category terms'? Note that a particular obstacle to this would be the lack of a taxonomy or taxonomy term meta – Tom J Nowell Aug 15 '14 at 17:00
  • Ah, so basically featured images for taxonomy terms – Tom J Nowell Aug 15 '14 at 18:10
  • I also like to use as little plugins as possible, but I do also like clean solutions and when it comes to taxonomy sometimes the solutions aren't always clean cut. If a client needs taxonomy images I use Categories Images plugin if you change your mind on using a plugin. – Howdy_McGee Aug 15 '14 at 18:21
  • Ill try playing with the answered option. If it will end up being even more messy code i will consider this plugin. thank you – nerijusgood Aug 15 '14 at 18:50
7

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/

  • That is actually pretty good. Still very hacky. – nerijusgood Aug 15 '14 at 17:38
  • 1
    @nerijusgood As there isn't default support, you have to hack. Maybe you can remove most of the options and only use the part that you need for storing image link. – sakibmoon Aug 15 '14 at 17:41
  • This answer is now obsolete, since it's pre WordPress 4.4, which introduced terms meta. – The J Dec 27 '16 at 3:55
5

You can use the Advanced Custom Fields plugin to add a custom field (an image field) to your custom taxonomy group.

  • Link only answers are not quite recommended. – Nilambar Jun 29 '15 at 3:15
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.