10

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.

4
  • 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
    Commented Aug 15, 2014 at 17:00
  • Ah, so basically featured images for taxonomy terms
    – Tom J Nowell
    Commented Aug 15, 2014 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
    Commented Aug 15, 2014 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 Commented Aug 15, 2014 at 18:50

3 Answers 3

8

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/

3
  • That is actually pretty good. Still very hacky. Commented Aug 15, 2014 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
    Commented Aug 15, 2014 at 17:41
  • This answer is now obsolete, since it's pre WordPress 4.4, which introduced terms meta.
    – The J
    Commented Dec 27, 2016 at 3:55
6

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

2
  • 1
    Link only answers are not quite recommended. Commented Jun 29, 2015 at 3:15
  • 1
    As a Developer i think I should avoid it
    – Ahadul
    Commented Jan 18, 2021 at 14:30
3

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 and acknowledge you have read our privacy policy.

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