Post #2

ACF Category Icons: How to Use for WordPress

Do you want to display your WordPress category/tag with an icon like this? That’s really easy with Advanced Custom Fields.

Add an custom image field with ACF, and set the rule to Taxonomy Term >> is equal to >> All. Save it, and this will activate image uploading options for both tags and categories. Now go to tags/categories section and upload your icon.

acf_custom_icon

Now add the code below to your archive.php template page.

<?php
  $queried_object = get_queried_object();
  <!-- 'icon' is the custom field name -->
  $thumbnail = get_field('icon', $queried_object);
?>
<?php if( !empty($thumbnail) ): ?>
  <img src="<?php echo $thumbnail; ?>" />
<?php endif; ?>

Have fun!

Leave a Reply