{"id":2997,"date":"2022-02-03T13:31:44","date_gmt":"2022-02-03T13:31:44","guid":{"rendered":"https:\/\/rengga.dev\/blog\/?p=2997"},"modified":"2023-06-12T14:34:27","modified_gmt":"2023-06-12T14:34:27","slug":"how-to-add-taxonomy-images-category-icon-in-wordpress","status":"publish","type":"post","link":"https:\/\/rengga.dev\/blog\/how-to-add-taxonomy-images-category-icon-in-wordpress\/","title":{"rendered":"How to Add Taxonomy Images (Category Icons) in WordPress"},"content":{"rendered":"<p><a href=\"https:\/\/rengga.dev\/blog\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #ff0000;\"><strong>Rengga Dev<\/strong><\/span><\/a> &#8211; Do you want to display taxonomy images or category icons in WordPress?<\/p>\n<p>By default, WordPress does not come with an option to upload a taxonomy image or category icon. It simply just displays a category or taxonomy name on the archive pages.<\/p>\n<p>In this article, we\u2019ll show you how to easily add taxonomy images or category icons in WordPress. We\u2019ll also show you how to display taxonomy images on your archive pages.<\/p>\n<h2><\/h2>\n<h2>Why Add Taxonomy Images in WordPress?<\/h2>\n<p>By default, your\u00a0WordPress website\u00a0does not come with an option to add images for your taxonomies like\u00a0categories and tags\u00a0(or any other custom taxonomy).<\/p>\n<p>It simply uses taxonomy names everywhere including the category archives or taxonomy archive pages.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-126434 lazyloaded aligncenter\" title=\"Plain taxonomy archive page\" src=\"https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/plain-taxonomy-archive.png\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" srcset=\"https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/plain-taxonomy-archive.png 680w, https:\/\/cdn3.wpbeginner.com\/wp-content\/uploads\/2017\/03\/plain-taxonomy-archive-300x124.png 300w\" alt=\"Plain taxonomy archive page\" width=\"680\" height=\"282\" data-ll-status=\"loaded\" \/><\/figure>\n<p>This looks kind of plain and boring.<\/p>\n<p>If you get a lot of search traffic to your taxonomy pages, then you may want to make them look more engaging.<\/p>\n<p>The easiest way to make a page more interesting is by adding images. You can add taxonomy images or category icons to make these pages more user-friendly and engaging.<\/p>\n<p>A good example of it is a site like NerdWallet that uses category icons in their header:<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-133861 lazyloaded aligncenter\" title=\"Category Icons example Nerdwallet\" src=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/category-icons-wordpress-example.png\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" srcset=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/category-icons-wordpress-example.png 680w, https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/category-icons-wordpress-example-300x87.png 300w\" alt=\"Category Icons example Nerdwallet\" width=\"680\" height=\"198\" data-ll-status=\"loaded\" \/><\/figure>\n<p>You can also use it create beautiful navigational sections on your homepage like Bankrate:<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-133862 lazyloaded aligncenter\" title=\"Category Icon Navigation Blocks\" src=\"https:\/\/cdn4.wpbeginner.com\/wp-content\/uploads\/2017\/03\/category-icon-navigation-blocks.png\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" srcset=\"https:\/\/cdn4.wpbeginner.com\/wp-content\/uploads\/2017\/03\/category-icon-navigation-blocks.png 680w, https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/category-icon-navigation-blocks-300x135.png 300w\" alt=\"Category Icon Navigation Blocks\" width=\"680\" height=\"307\" data-ll-status=\"loaded\" \/><\/figure>\n<p>That being said, let\u2019s take a look at how to easily add taxonomy images in WordPress.<\/p>\n<h2><\/h2>\n<h2>Easily Add Taxonomy Images in WordPress<\/h2>\n<p>First thing you need to do is install and activate the\u00a0<a title=\"Categories Images\" href=\"https:\/\/wordpress.org\/plugins\/categories-images\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Categories Images<\/a>\u00a0plugin. For more details, see our step-by-step guide on\u00a0how to install a WordPress plugin.<\/p>\n<p>Upon activation, you can simply go to the\u00a0<strong>Posts \u00bb Categories<\/strong>\u00a0page. You\u2019ll notice the plugin will be showing a placeholder image for your existing categories.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-126435 lazyloaded aligncenter\" title=\"Default placeholder image\" src=\"https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/default-image.png\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" srcset=\"https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/default-image.png 680w, https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/default-image-300x124.png 300w\" alt=\"Default placeholder image\" width=\"680\" height=\"282\" data-ll-status=\"loaded\" \/><\/figure>\n<p>To choose your own category icon, you need to click on the Edit link below a category.<\/p>\n<p>On the Edit category page, scroll down to the bottom and you\u2019ll find a form to upload your own taxonomy image.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-126436 lazyloaded aligncenter\" title=\"Upload new taxonomy image\" src=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/upload-new-image.png\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" srcset=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/upload-new-image.png 680w, https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/upload-new-image-300x111.png 300w\" alt=\"Upload new taxonomy image\" width=\"680\" height=\"251\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Simply click on the \u2018Upload\/Add New Image\u2019 button to upload the image you want to use for that particular category.<\/p>\n<p>Don\u2019t forget to click on the Add Category or Update button to save your changes.<\/p>\n<p>Next, you can repeat the process to upload images for other category images. You can also upload images for your tags and any other taxonomies as well.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-126437 lazyloaded aligncenter\" title=\"Categories with thumbnail images\" src=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/category-with-thumbnail-images.png\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" srcset=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/category-with-thumbnail-images.png 680w, https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/category-with-thumbnail-images-300x136.png 300w\" alt=\"Categories with thumbnail images\" width=\"680\" height=\"308\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Now the problem is that after adding the images, if you visit a category page, then you won\u2019t see your category image there.<\/p>\n<p>To display it, you will need to edit your WordPress theme or\u00a0child theme. If this is your first time editing WordPress files, then you may want to see our guide on\u00a0how to copy and paste code in WordPress.<\/p>\n<p>First, you will need to connect to your WordPress site using an\u00a0FTP client or your\u00a0WordPress hosting\u00a0file manager.<\/p>\n<p>Once connected, you will need to find the template responsible for displaying your taxonomy archives. This could be archives.php, category.php, tag.php, or taxonomy.php files.<\/p>\n<p>For more details, see our guide on how to\u00a0find which files to edit in a WordPress theme.<\/p>\n<p>Once you have found the file, you\u2019ll need to download it to your computer and open in a\u00a0text editor\u00a0like Notepad or TextEdit.<\/p>\n<p>Now paste the following code where you want to display your taxonomy image. Usually, you would want to add it before the taxonomy title or\u00a0<code>the_archive_title()<\/code>\u00a0tag.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php if( is_category() ) { ?&gt; \r\n&lt;div class=\"taxonomy-image\"&gt;\r\n&lt;img class=\"taxonomy-img\" src=\"&lt;?php if (function_exists('z_taxonomy_image_url')) echo z_taxonomy_image_url(); ?&gt;\"  alt=\"\" \/ &gt;\r\n&lt;\/div&gt;\r\n&lt;?php \r\n} else {  \r\n\/\/do nothing\r\n} \r\n?&gt;<\/pre>\n<p>After adding the code, you need to save this file and upload it back to your website using FTP.<\/p>\n<p>You can now visit the taxonomy archive page to see it display your taxonomy image. Here is how it looked on our demo archive page.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-126439 lazyloaded aligncenter\" title=\"Category with image\" src=\"https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/taxonomy-with-image.png\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" srcset=\"https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/taxonomy-with-image.png 680w, https:\/\/cdn3.wpbeginner.com\/wp-content\/uploads\/2017\/03\/taxonomy-with-image-300x124.png 300w\" alt=\"Category with image\" width=\"680\" height=\"282\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Now, it may still look a bit awkward, but don\u2019t worry. You can style that using a little bit of\u00a0custom CSS.<\/p>\n<p>Here is the custom CSS we used for the taxonomy image.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">img.taxonomy-img {\r\n    float: left;\r\n    max-height: 100px;\r\n    max-width: 100px;\r\n    display: inline-block;\r\n}<\/pre>\n<p>Depending on your theme, you may also need to style surrounding elements like taxonomy title and description.<\/p>\n<p>We simply wrapped our taxonomy archive title and description in a\u00a0<code>&lt;div&gt;<\/code>\u00a0element and added a custom CSS class. We then used the following CSS code to adjust title and description.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">.taxonomy-title-description {\r\n    display: inline-block;\r\n    padding: 18px;\r\n}<\/pre>\n<p>Here is how it looked afterward on our test website.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-126443 lazyloaded aligncenter\" title=\"After adding custom CSS\" src=\"https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/after-custom-css.png\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" srcset=\"https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/after-custom-css.png 680w, https:\/\/cdn.wpbeginner.com\/wp-content\/uploads\/2017\/03\/after-custom-css-300x124.png 300w\" alt=\"After adding custom CSS\" width=\"680\" height=\"282\" data-ll-status=\"loaded\" \/><\/figure>\n<h2><\/h2>\n<h2>Exclude Taxonomies from Displaying Taxonomy Images<\/h2>\n<p>Now some users may only want to use taxonomy images for specific taxonomies.<\/p>\n<p>For instance, if you run an\u00a0online store\u00a0using WooCommerce, then you may want to exclude product categories.<\/p>\n<p>Simply go back to the Categories Images page in WordPress admin area and check the taxonomies you want to exclude.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-126445 lazyloaded aligncenter\" title=\"Exclude categories\" src=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/exclude-categories.png\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" srcset=\"https:\/\/cdn2.wpbeginner.com\/wp-content\/uploads\/2017\/03\/exclude-categories.png 680w, https:\/\/cdn4.wpbeginner.com\/wp-content\/uploads\/2017\/03\/exclude-categories-300x136.png 300w\" alt=\"Exclude categories\" width=\"680\" height=\"309\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Don\u2019t forget to click on the Save Changes button to store your settings.<\/p>\n<p>We hope this article helped you learn how to easily add taxonomy images in WordPress. You may also want to see these useful\u00a0category hacks and plugins for WordPress\u00a0or see our tips on\u00a0getting more traffic\u00a0from search engines.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rengga Dev &#8211; Do you want to display taxonomy images or category <a class=\"read-more\" href=\"https:\/\/rengga.dev\/blog\/how-to-add-taxonomy-images-category-icon-in-wordpress\/\" title=\"How to Add Taxonomy Images (Category Icons) in WordPress\" itemprop=\"url\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":3763,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,17],"tags":[257,131,136],"newstopic":[595],"class_list":{"0":"post-2997","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-web-development","8":"category-wordpress","9":"tag-category-icons-wordpress","10":"tag-taxonomy-images-wordpress","11":"tag-wordpress-plugin","12":"newstopic-wordpress"},"_links":{"self":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/2997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/comments?post=2997"}],"version-history":[{"count":2,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/2997\/revisions"}],"predecessor-version":[{"id":3000,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/2997\/revisions\/3000"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media\/3763"}],"wp:attachment":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media?parent=2997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/categories?post=2997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/tags?post=2997"},{"taxonomy":"newstopic","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/newstopic?post=2997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}