How to Display Image on Taxonomy with Advanced Custom Fields (ACF)

Sometimes things that should be easy are hard…

Today, I needed to display an Advanced Custom Fields (ACF) image on a custom taxonomy page.  Here’s the solution:

First, create the image field and apply it to the taxonomy like this:
acf image field on

Make sure you have the image field set to output the “Image Array” like this:
acf array

Now, go to your taxonomy term and add an image like this:
acf add image to

Finally, copy-and-paste code to your functions.php:


add_action( 'loop_end', 'output_before_taxonomy_loop' );
function output_before_taxonomy_loop(){
	if (is_tax()) {
		
		// Display the artist image
		$queried_object = get_queried_object();
		$taxonomy = $queried_object--->taxonomy;
		$term_id = $queried_object->term_id;
		$terms = get_field( 'artist_image', $taxonomy.'_'.$term_id);
		
		if( $terms ) {
			
			echo '<img src="'. $terms['url'] .'">';
		    
		} else {
		    //do nothing
		}
   
	}
}

Finally, bask in the glory that is Advanced Custom Fields’ taxonomy image fields!

acf taxonomy image display
Artist is https://cryns.com

Ain’t life grand? Well…mostly?

Posted in

Toby Cryns

RSS From Toby’s Blog

  • WordPress Maintenance Checklist: Keep Your Site Running Smoothly
    Discover the essential tasks for effective WordPress maintenance and ensure your website runs smoothly and securely with our comprehensive guide.
  • Why We Don’t Automate Our WordPress Hosting Business
    There are some great platforms out there to automate your website hosting biz: But we don’t use any of them. Here’s why: Hosting companies only get worse over time. Over the years, I’ve hosted websites on a bunch of platforms: All of these hosting companies share one thing in common: Over time, they all got…
  • Fortify Your WordPress Site: Essential Security Steps
    Securing your WordPress site is a critical component of maintaining your online presence and safeguarding your data. Security is no longer a luxury, it has become a necessity in today’s digital world, where threats are lurking at every corner. This piece dives deep into WordPress security basics, giving you a comprehensive understanding of common vulnerabilities…

More posts from themightymo.com

The Mighty Moo! WordPress Theme Version 1.2.4 Update

By | April 3, 2009

I added the following functionality to The Mighty Moo! WordPress theme: Custom stylesheet class example Basically, what I did was add an example to the custom stylesheet to get you rolling.  🙂

The Mighty Moo! WordPress Theme – Version 1.2.3

By | March 26, 2009

I just completed another series of updates to “The Mighty Moo!” WordPress theme.  Version 1.2.3 adds: Page Template Widgetized Sidebars underneath the content Moved javaScript code into footer.php Theme image files (these were accidentally left out of previous releases) Download it today!

The Mighty Moo! WordPress Theme, Version 1.2.2 Released

By | March 25, 2009

Today, I spent eight hours making a number of significant updates to The Mighty Moo! WordPress theme.  This set of updates increases the version number to 1.2.2. and include: Single Page template  Comment Threading Fixed Commenting bug Custom Style Sheet (Upgrades now won’t mess up your custom CSS edits!) The next round of updates will…

RSS From Toby’s Blog

  • WordPress Maintenance Checklist: Keep Your Site Running Smoothly
    Discover the essential tasks for effective WordPress maintenance and ensure your website runs smoothly and securely with our comprehensive guide.
  • Why We Don’t Automate Our WordPress Hosting Business
    There are some great platforms out there to automate your website hosting biz: But we don’t use any of them. Here’s why: Hosting companies only get worse over time. Over the years, I’ve hosted websites on a bunch of platforms: All of these hosting companies share one thing in common: Over time, they all got…
  • Fortify Your WordPress Site: Essential Security Steps
    Securing your WordPress site is a critical component of maintaining your online presence and safeguarding your data. Security is no longer a luxury, it has become a necessity in today’s digital world, where threats are lurking at every corner. This piece dives deep into WordPress security basics, giving you a comprehensive understanding of common vulnerabilities…