Home » Experts Only » WordPress Custom Post Type Category Images : Solved

WordPress Custom Post Type Category Images : Solved

If you’re a WordPress developer, you’ve probably been here.

You want to use images for your categories, but they are custom taxonomies. Here’s how to solve that issue. We’re using a plugin called “Category Images” by Muhammad Said El Zahlan.

Download, install and activate the plugin. Now you can add images to your categories in any post type (or terms). You can even exclude post types if you want to keep things local to a single category. Now you want to display those images somewhere. There’s plenty of documentation on the author’s site but in our case we needed  to loop through the categories and display the image in a javascript portfolio plugin.

In our file we added the line:

<?php foreach (get_terms(‘v-category’) as $cat) : ?>

Where v-category is the slug of our custom taxonomy.

Next we needed to display the image and the category name.

<img width=”700″ height=”700″ src=”<?php echo z_taxonomy_image_url($cat->term_id); ?>” class=”scale-with-grid wp-post-image” alt=”” />

<h2 class=”nvr-pf-title”><a href=”<?php echo get_term_link($cat->slug, ‘v-category’); ?>”><?php echo $cat->name; ?></a></h2>

Then ending foreach:

<?php endforeach; ?>

That’s it. Displays like a champ.

More Web Design Blog Content

An Accessibility Mindset

How often do you receive this response when inquiring about making a website more accessible? We wish we could devote more resources to it, but at the moment we just don’t know enough to get started. The value and necessity of making websites accessible are generally recognized. Almost

Sitemaps

Back in the day a simple website could get away with an on-page sitemap. Just a simple list of pages somewhere on the site. Not so much anymore. Sitemaps – at least the ones we intend for search engines to look at – are all internal. We use

Maintaining Correct Site Structure

One of the biggest holes in a client’s SEO (pre livewire SEO, that is) is almost always the site structure. So many SEO companies focus on content and backlinks that quality code is often overlooked. There are many cases where we have come into the tail end of

Thomas Jackson Updates

John Pailing and I have been hard at work upgrading what is already an incredible website. We have made several layout changes and are playing with a few ideas that will really add to the depth and relevance of the site. It is truly an honor to be

The Amazon Dams Network

Proud to present the first online version of the Amazon Dams Network. This has been a project Livewire has been working on for several months with the University of Florida and other members from around the world. This has been a very exciting project and we are pleased

Is PPC Advertising Worth It?

The answer is: it depends. In our experience it really comes down to your industry, your ad’s effectiveness and … dum de dum dum … money. First, your industry should be visible online in the first place. Holly’s Bakery is probably going to do fine on Google ads