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:
Make sure you have the image field set to output the “Image Array” like this:
Now, go to your taxonomy term and add an image like this:
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!
Ain’t life grand? Well…mostly?
More posts from themightymo.com
Mark Gason Papervision 3D Presentation at FlashMN
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
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!
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…