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

Hey, Look What We Did…

Our programmers are the best in the business. We just finished a great new project at referralfeelawyers.com. This service connects lawyers with lawyers that pay referral fees for, you guessed it, referrals. The website features custom attorney profiles, administrative control over practice areas and geographical data….all kinds of

Extend Your iPhone or iPad Battery Life

A common problem in todays world – batteries haven’t really kept up with the rest of the tech world and are absolutely the weak link in virtually any modern day tech pack. Things have gotten better over the years. My smartphone lasts about 18 hours depending on usage

WordPress Experts: Getting Slug by Single_Cat_Title

An interesting problem that I came across in a recent project. The client needed a custom post taxonomy set to a gallery of choices on a featured section of their website. First we needed to add custom post types and category images plugins. Iterating through the taxonomy was

Google Local

In today’s digital world, it is essential for businesses to have an online presence. Google Maps is one of the most significant tools for local companies, since it helps potential customers locate and learn about your business. Having a presence on Google Maps is not sufficient; you must

Getting Accurate Shipping Rates

If you own an ecommerce store and provide real time shipping rates you have likely encountered a long list of issues with returning accurate rates. If you have not, Bravo good sir or madam! You are the exception. Having real-time shipping rates on your online store is a