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

  • How Digital Ocean Cost Us Thousands of Dollars in a Single Day
    Here’s the rub for me: My belief is that bad stuff happens, and you need to own it. Digital Ocean definitely did not own it in this case. I wonder how the original founders of Digital Ocean would have reacted had they been in charge… For example, wouldn’t it be nice if an actual human… […]
  • Where uncertainty exists, don’t order specific.
    4 Idiot Case Studies with 2 simple age-old business lessons. The post Where uncertainty exists, don’t order specific. appeared first on Toby Cryns, WordPress Trainer in Minneapolis, MN.
  • “Now THAT was a good meeting!”
    A single effective meeting can change the course of history for a company. Imagine if you could lead effective meetings EVERY DAY! You can, but it takes curiosity & practice. This article is a good place to start your journey to a more effective you. The post “Now THAT was a good meeting!” appeared first […]

More posts from themightymo.com

Mark Gason Papervision 3D Presentation at FlashMN

By | February 18, 2009

I am liveblogging from Mark Gason’s presentation at FlashMN. These are my notes. Check out Mark’s page of resources.  It contains links to tutorials as well as all sorts of other Papervision 3D-related stuff.  http://gasolicious.com/flashstuff/PV3D_presentation.html Swift 3D is better than Papervision 3D in some ways: – You can model in Swift 3D, but AutoCAD also…

Reorganize Your WordPress 2.7 Admin Panel with Fluency 2.0

By | February 6, 2009

Yesterday I discovered the new Fluency 2.0 plugin for WordPress 2.7.  It does a fantastic job of cleaning up the admin interface and makes the back-end WordPress experience much better for users.

We Now Offer Search Engine Optimization!

By | February 2, 2009

We have just teamed up with one of the web’s finest search engine optimization gurus, Greg Cryns, and will now be offering his services to you, our customers! For you, our customer, this means that we now have added expertise in driving targeted traffic to your website. Greg has over a decade worth of search…

RSS From Toby’s Blog

  • How Digital Ocean Cost Us Thousands of Dollars in a Single Day
    Here’s the rub for me: My belief is that bad stuff happens, and you need to own it. Digital Ocean definitely did not own it in this case. I wonder how the original founders of Digital Ocean would have reacted had they been in charge… For example, wouldn’t it be nice if an actual human… […]
  • Where uncertainty exists, don’t order specific.
    4 Idiot Case Studies with 2 simple age-old business lessons. The post Where uncertainty exists, don’t order specific. appeared first on Toby Cryns, WordPress Trainer in Minneapolis, MN.
  • “Now THAT was a good meeting!”
    A single effective meeting can change the course of history for a company. Imagine if you could lead effective meetings EVERY DAY! You can, but it takes curiosity & practice. This article is a good place to start your journey to a more effective you. The post “Now THAT was a good meeting!” appeared first […]