Display ACF Custom Field from Custom Taxonomy specific term outside a query/loop

[ad_1]

Hello there!

I’ve created an image field for a Custom Taxonomy with ACF.

Now I need to show each of the images set with this field in a Image widget or as a container’s backgroud image on the first section of the home page.

I’ve thought of going with creating a Loop Carousel with only one slide, which could be a Loop Item composed by the image field set as the dynamic tag and query it with the correct terms set. I’ve tested this idea and it already works that way.
(disclaimer: I can’t just use a loop carousel to display all of them instead, because it’s a custom design with some custom html, js and css already making use of the Testimonial widget synced with text/titles and bg slide gallery).

**But:**

The problem is that there are around 12 images to be displayed in this (hero) section this way, as I need all of this taxonomy’s terms images to be displayed, therefore they would sum up to around 12 Loop Carousels, and that’s way too much bloat to the first section of any website (unless I’m mistaken about this).

I couldn’t use this image field with each term of this taxonomy individualy as a dynamic tag, since it’s bound to “Taxonomy form” setting in ACF, so it’s only presented in queries… I’m searching for a way to implement a [custom location](https://www.advancedcustomfields.com/resources/custom-location-rules/) to create 6 separate image fields, setting each one of them respectively for each of this taxonomy’s terms (there are 6 terms), but I’m afraid it won’t be possible either.

So here are my questions:

1. Would the “[custom location rule](https://www.advancedcustomfields.com/resources/custom-location-rules/)” guided by ACF itself work in this case?
2. Is there a way to set a custom field from a custom taxonomy’s specific term individually outside a query/loop, in an isolated widget or are they useless outside loops?

P.S.:
I have also found [this](https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/) explaining how to set a fild group to a specific taxonomy term, but not only this dropdown option is not present in the location rules as in the end of tutorial I there’s the code representing how to get the field values and apparently it has to be queried, so it’d probably be in vain.

**P.S.II:**
Just found the following possible solution via **shortcode dynamic tag:**
(I can see how, and know that for getting the image it’s some other argument, other than “get\_field()” and maybe including the image link, but I lack the knowledge to manipulate it\*\*)\*\*

`//Set Shortcode to “Attributes” dymanic tag with the following as the shortcode content: style|background-color:[thumb-ext]`

`//test alternative: term_taxonomy_id`

`function thumb_ext_shortcode() {`

`global $post;`

`$post_id = $post->ID;`

`$term_list = wp_get_post_terms($post_id, ‘ambiente’, array(‘fields’ => ‘ids’));`

`$term_id = 0;`

`$thumb = get_field(‘ambiente_thumb’, ‘term_’.$term_id);`

`if($thumb) {`

`return $thumb;`

`} else {`

`return ”;`

`}`

`}`

`add_shortcode(‘thumb-ext’, ‘thumb_ext_shortcode’);`

**Thanks in advance** to anyone willing to put some thought on this with me, much appreciated!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer