WordPress categories are not like regular posts, there are no “featured image” inputs. With the magic of Advanced Custom Fields, a plugin for adding custom input fields, we can add the image area. The real trick is displaying that image onto your category page. In this short article I will show you how to add an image to a WordPress category.

Advanced Custom Fields

  1. Install and activate Advanced Custom Fields
  2. Create a new field group named “Category”
  3. Add a field named “Category Image”
  4. In rules, show the field if taxonomy is equal to category
  5. Save.

Go to your desired category and set whichever image you want to be your categories image.

Now comes the only coding you will need to do during this whole process.


Archives.. Get it?

Open up your archives.php file and enter the following right below get_header().

// Gets the object that you want
// It comes back as an object of associative arrays
$term = get_queried_object();

Now go to where you want the image to appear and enter the following:

<div style="background-image: url(<?php echo get_field('category_image', $term); ?>); height: 300px"></div>

This code calls the image you added to your category via Advanced Custom Fields and displays it as a background image. Of course you can change the HTML, make it an <img> tag if you want or change the height.

This is the easiest and safest way to add an image to a WordPress category. It took a lot of trial and error, using other methods but this one came out on top. WordPress should have the ability to add and image to a WordPress category built in. It doesn’t make much sense why they wouldn’t have it come in every install.

Like all great things in life, nothing comes easy. If this post helped you, let me know below. Make sure to check out my other posts as well, they’re full of great bits of knowledge!