Hi sorry for the delay the replies filtered to my junk for some reason.
I don’t fully understand.
So I have set up featured_page_link as a taxonomy product_cat and selected the category in the page editor. So basically all I want to do is set the link in my template to go to the woocommerce category I have selected within the admin tool.
Thanks,
Kev
IGNORE ME!!!
I re-read this:
https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/
and it works fine…
Apologies. 🙂
what name should it have?
Array
(
[ID] => 0
[key] => field_5fad1c053194c
[label] =>
[name] => acf[field_5fad1c053194c]
[prefix] => acf
[type] => group
[value] => Array
(
[field_5fad1f55299f4] =>
[field_5fad1c313194d] => 1
[field_5fad1c493194e] => Array
(
[0] => Array
(
[field_5fad1c733194f] => Emergenze
[field_5fad1d7e31954] => 1
[field_5fad643cea81d] => Array
(
[field_5f9c1fb8b4913] => Array
(
[field_5f9c211cb4914] => 6925
[field_5f9c27fab4915] => Scopri di più
)
)
[field_5fad1cde31950] => Lorem ipsum
[field_5fad1cf131951] => Prestiamo soccorso alle popolazioni vittime di emergenze umanitarie, attraverso la distribuzione di beni primari e la ricostruzione. Oltre l’emergenza, creiamo le condizioni perché l’aiuto si trasformi in un percorso di sviluppo e autonomia per le comunità locali.
[field_5fad1dea31955] => 7004
)
[1] => Array
(
[field_5fad1c733194f] => Sviluppo
[field_5fad1d7e31954] => 0
[field_5fad643cea81d] => Array
(
[field_5f9c1fb8b4913] => Array
(
[field_5f9c211cb4914] =>
[field_5f9c27fab4915] =>
)
)
[field_5fad1cde31950] => Test
[field_5fad1cf131951] => Prestiamo soccorso alle popolazioni vittime di emergenze umanitarie, attraverso la distribuzione di beni primari e la ricostruzione. Oltre l’emergenza, creiamo le condizioni perché l’aiuto si trasformi in un percorso di sviluppo e autonomia per le comunità locali. Prestiamo soccorso alle popolazioni vittime di emergenze umanitarie, attraverso la distribuzione di beni primari e la ricostruzione. Oltre l’emergenza, creiamo le condizioni perché l’aiuto si trasformi in un percorso di sviluppo e autonomia per le comunità locali.
[field_5fad1dea31955] => 7007
)
)
)
[menu_order] => 0
[instructions] =>
[required] => 0
[id] => acf-field_5fad1c053194c
[class] =>
[conditional_logic] => 0
[parent] => group_5fad1bae10663
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[layout] => block
[wpml_cf_preferences] => 0
[_name] => featured_blocks
[_valid] => 1
[sub_fields] => Array
(
[0] => Array
(
[ID] => 0
[key] => field_5fad1f55299f4
[label] => Informazioni
[name] =>
[prefix] => acf
[type] => message
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5fad1c053194c
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[wpml_cf_preferences] => 0
[message] => In evidenza mostra in alto alla pagina subito dopo la testata uno o più blocchi (con metodologia tab) contenenti titolo, descrizione, immagine ed eventuale link se reso visibile della pagina selezionata.
[new_lines] => wpautop
[esc_html] => 0
[_name] =>
[_valid] => 1
)
[1] => Array
(
[ID] => 0
[key] => field_5fad1c313194d
[label] => Attivo
[name] => is_active
[prefix] => acf
[type] => true_false
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5fad1c053194c
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[message] =>
[default_value] => 0
[ui] => 1
[ui_on_text] =>
[ui_off_text] =>
[wpml_cf_preferences] => 0
[_name] => is_active
[_valid] => 1
)
[2] => Array
(
[ID] => 0
[key] => field_5fad1c493194e
[label] => Blocchi in evidenza
[name] => items
[prefix] => acf
[type] => repeater
[value] =>
[menu_order] => 2
[instructions] =>
[required] => 1
[id] =>
[class] =>
[conditional_logic] => Array
(
[0] => Array
(
[0] => Array
(
[field] => field_5fad1c313194d
[operator] => ==
[value] => 1
)
)
)
[parent] => field_5fad1c053194c
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[wpml_cf_preferences] => 0
[collapsed] => field_5fad1c733194f
[min] => 1
[max] => 0
[layout] => block
[button_label] => Aggiungi blocco
[_name] => items
[_valid] => 1
[sub_fields] => Array
(
[0] => Array
(
[ID] => 0
[key] => field_5fad1c733194f
[label] => Etichetta
[name] => label
[prefix] => acf
[type] => text
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 1
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5fad1c493194e
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[wpml_cf_preferences] => 2
[default_value] =>
[placeholder] =>
[prepend] =>
[append] =>
[maxlength] =>
[_name] => label
[_valid] => 1
)
[1] => Array
(
[ID] => 0
[key] => field_5fad1d7e31954
[label] => Link a pagina
[name] => cta_is_active
[prefix] => acf
[type] => true_false
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5fad1c493194e
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[wpml_cf_preferences] => 0
[message] =>
[default_value] => 0
[ui] => 1
[ui_on_text] =>
[ui_off_text] =>
[_name] => cta_is_active
[_valid] => 1
)
[2] => Array
(
[ID] => 0
[key] => field_5fad643cea81d
[label] =>
[name] => link
[prefix] => acf
[type] => clone
[value] =>
[menu_order] => 2
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => Array
(
[0] => Array
(
[0] => Array
(
[field] => field_5fad1d7e31954
[operator] => ==
[value] => 1
)
)
)
[parent] => field_5fad1c493194e
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[clone] => Array
(
[0] => group_5f9c1faa3f1a8
)
[display] => group
[layout] => block
[prefix_label] => 1
[prefix_name] => 0
[wpml_cf_preferences] => 0
[_name] => link
[_valid] => 1
[sub_fields] => Array
(
[0] => Array
(
[ID] => 0
[key] => field_5f9c1fb8b4913
[label] =>
[name] => link_to_page
[prefix] => acf
[type] => group
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => group_5f9c1faa3f1a8
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[wpml_cf_preferences] => 1
[layout] => block
[_name] => link_to_page
[_valid] => 1
[sub_fields] => Array
(
[0] => Array
(
[ID] => 0
[key] => field_5f9c211cb4914
[label] => Collegamento
[name] => post
[prefix] => acf
[type] => post_object
[value] =>
[menu_order] => 0
[instructions] => Seleziona il collegamento dall'elenco.
[required] => 1
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5f9c1fb8b4913
[wrapper] => Array
(
[width] => 50
[class] =>
[id] =>
)
[wpml_cf_preferences] => 1
[post_type] => Array
(
[0] => page
)
[taxonomy] =>
[allow_null] => 0
[multiple] => 0
[return_format] => object
[ui] => 1
[_name] => post
[_valid] => 1
)
[1] => Array
(
[ID] => 0
[key] => field_5f9c27fab4915
[label] => Etichetta pulsante
[name] => label
[prefix] => acf
[type] => text
[value] =>
[menu_order] => 1
[instructions] => Se il campo non viene valorizzato, viene preso automaticamente il titolo.
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5f9c1fb8b4913
[wrapper] => Array
(
[width] => 50
[class] =>
[id] =>
)
[wpml_cf_preferences] => 2
[default_value] =>
[placeholder] =>
[prepend] =>
[append] =>
[maxlength] =>
[_name] => label
[_valid] => 1
)
)
[_clone] => field_5fad643cea81d
[__key] => field_5f9c1fb8b4913
[__name] => link_to_page
[__label] =>
)
)
)
[3] => Array
(
[ID] => 0
[key] => field_5fad1cde31950
[label] => Titolo
[name] => title
[prefix] => acf
[type] => text
[value] =>
[menu_order] => 3
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5fad1c493194e
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[wpml_cf_preferences] => 2
[default_value] =>
[placeholder] =>
[prepend] =>
[append] =>
[maxlength] =>
[_name] => title
[_valid] => 1
)
[4] => Array
(
[ID] => 0
[key] => field_5fad1cf131951
[label] => Descrizione
[name] => description
[prefix] => acf
[type] => textarea
[value] =>
[menu_order] => 4
[instructions] =>
[required] => 1
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5fad1c493194e
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[default_value] =>
[placeholder] =>
[maxlength] =>
[rows] => 3
[new_lines] =>
[wpml_cf_preferences] => 2
[_name] => description
[_valid] => 1
)
[5] => Array
(
[ID] => 0
[key] => field_5fad1dea31955
[label] => Immagine
[name] => image_desktop
[prefix] => acf
[type] => image_aspect_ratio_crop
[value] =>
[menu_order] => 5
[instructions] =>
[required] => 1
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5fad1c493194e
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[wpml_cf_preferences] => 0
[crop_type] => aspect_ratio
[aspect_ratio_width] => 567
[aspect_ratio_height] => 401
[return_format] => array
[preview_size] => full
[library] => all
[min_width] =>
[min_height] =>
[min_size] =>
[max_width] =>
[max_height] =>
[max_size] =>
[mime_types] =>
[_name] => image_desktop
[_valid] => 1
)
)
)
)
[_prepare] => 1
)
Hi,
with the filter you provided me the answer is this below.
The group is simple and is not contained in other groups or a clone.
Array
(
[ID] => 0
[key] => field_5f1b04a650dbe
[label] =>
[name] => acf[field_5f1b04a650dbe]
[prefix] => acf
[type] => group
[value] => Array
(
[field_5fad6bdaa2903] => 1
[field_5f1b0571deda4] =>
)
[menu_order] => 0
[instructions] =>
[required] => 0
[id] => acf-field_5f1b04a650dbe
[class] =>
[conditional_logic] => 0
[parent] => group_5f1b04a64d28d
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[layout] => block
[_name] => link_scope_pages
[_valid] => 1
[sub_fields] => Array
(
[0] => Array
(
[ID] => 0
[key] => field_5fad6bdaa2903
[label] => Automatico
[name] => is_automatic
[prefix] => acf
[type] => true_false
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => field_5f1b04a650dbe
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[message] =>
[default_value] => 1
[ui] => 1
[ui_on_text] =>
[ui_off_text] =>
[wpml_cf_preferences] => 0
[_name] => is_automatic
[_valid] => 1
)
[1] => Array
(
[ID] => 0
[key] => field_5f1b0571deda4
[label] => Seleziona pagine ambito
[name] => items
[prefix] => acf
[type] => relationship
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 1
[id] =>
[class] =>
[conditional_logic] => Array
(
[0] => Array
(
[0] => Array
(
[field] => field_5fad6bdaa2903
[operator] => !=
[value] => 1
)
)
)
[parent] => field_5f1b04a650dbe
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[post_type] => Array
(
[0] => page
)
[taxonomy] =>
[filters] => Array
(
[0] => search
)
[elements] => Array
(
[0] => featured_image
)
[min] =>
[max] =>
[return_format] => object
[wpml_cf_preferences] => 0
[_name] => items
[_valid] => 1
)
)
[_prepare] => 1
)

This is really a general WP question and not related to ACF.
First off, if this is showing only posts in one category then you need should have a taxonomy template "taxonomy-{$taxonomy}.php" or a term template "taxonomy-{$taxonomy}-{$term}.php" https://developer.wordpress.org/themes/basics/template-hierarchy/
If you are trying to show multiple terms and sort the posts by term, this is not something that is native to WP. You need to get the list of terms and then loop over them doing a separate post query for each term, https://wordpress.stackexchange.com/questions/151669/sort-posts-by-category

Check out this link, it might help you https://support.advancedcustomfields.com/forums/topic/conditional-logic-using-taxonomy-field/page/5/
Hi John,
Thanks for your reply. Actually, yes, “A” and “B” are taxonomies for the “Member” Custom Post Type. I going to search into the forum for “conditional logic on taxonomy field”.

A taxonomy field returns a single term of an array of terms dependent on the settings for the field. See code examples here for how to use a taxonomy field https://www.advancedcustomfields.com/resources/taxonomy/
Your issue with Uncategorized is that in your code get_term() requires you to pass the taxonomy name or “category” is assumed, meaning the default category taxonomy for posts.
Thanks John,
I see where you’re going. And good caution on having too many filters/Queries.
Using “foreach”, maybe something like this?
// append meta query
$meta_query = array(
'relation' => 'AND',
foreach( $value as $val )
{
array(
'relation' => 'OR',
array(
'key' => $name,
'value' => '"' . $val . '"',
'compare' => 'LIKE',
),
),
});
I went a different route and decided to utilize custom taxonomies, in combination with the Taxonomy field. But still utilizing the Javascript Elliot outlined in the tutorial. Seems to be less intensive query and built into WordPress already.
Thanks again for your response.

Is “A” “B” type members also a taxonomy? If it is then this is not possible with ACF alone. There have been solutions for this in the past. Try searching the forum for something like “conditional logic on taxonomy field”
If this is not the case, what type of field is the “A” “B” type field?
I made a typo. Correct use of the function
get_term_link( $term, $taxonomy = '' ); // $term is the term object, ID, or slug whose link will be retrieved
In this case, ‘featured_page_link’ should return an ID (integer) or object term.
For anyone who needs it, my error was that I had to use
get_term_link(term-slug, taxonomy-slug) with the term slug and the taxonomy slug, while I was using the ID and did not use the taxonomy slug.
So the final code I used is:
$terms = get_field('acf_tax_fieldname');
if( $terms ) {
foreach( $terms as $term ) {
$term_name = get_term( $term )->name;
$term_slug = get_term( $term )->slug;
$term_link = get_term_link( $term_slug , 'wp_tax_slug' );
echo "<a href='" . $term_link . "'>" . $term_name . "</a>";
}
}
The plugin Smitxv mentions above : https://github.com/mattkeys/ACF-Conditional-Taxonomy-Rules is exactly what I needed. Allowing conditional based on chosen Taxonomy ID. Maybe that should be added to future release of ACF.
Thanks.

Reading in 10k posts and then looping over them will likely cause other issues with performance due to the data returned in the query and memory.
The biggest issue to speed is that regex on the date and the number of fields your using to filter.
If I needed to do something similar to this and knew it before I started I would have a separate field (not in ACF, just your standard WP custom meta field). I would create and acf/save_post filter. In this filter I would get the date field, extract the year and save just the year into this other field. The I could do a simple ‘==’ compare on this field. This would greatly improve the performance of the query.
But with 10k posts to look at it might still be a little slow. If it was I would likely use WP transients to store the results of the query for a time. This would mean the query would only need to be run once every few days.
You could also have a taxonomy for the year, as in one of the points you listed, with the right settings you can actually hide this taxonomy. Instead of saving the year in another fields as in my first suggestion the acf/save_post filter would set the correct term in the year taxonomy.
Post meta can be used for filtering, however, the filtering needs to be limited and the use of things like “LIKE” and “REGEXP” are going to cause performance issues.
I also have one site, this site has “Products” and there are (no lie) 18 different filters used on this site. Trying to filter by 18 custom fields would simply time out the load of the page. In this case, when a new “Product” is saved a CRON is triggered. This CRON runs through all of the possible values for every filter and stores the results. On the front end of the site I use this information to query the posts.
Use a WP option, lets call this option “birth_years”. This option would be an array with this architecture.
$birth_years = array (
// each element of this array is "YEAR" => array()
"2020" => array (
// each element of this array is a post ID of a person in this year
1, 2, 3, 4, 5
)
);
Create an acf/save_post filter with a priority of 1 so that it runs before ACF saves the value of the date field. See the doc for this filter. In this filter I would compare the old value with the new value. If it is the same I would do nothing. If it is different I would get the option, remove this person’s post ID from the old year and add it to the new year in my array.
Then when doing the query for people in the same year I would get the option add this to my query
'post__in' => $birth_year['2020']
completely eliminating the meta query.
Hope some of this information helps you
Ok I got this to work as needed as a multi select. I’m currently using product categories taxonomy, is it possible to get the multi select to pick up the woo products instead of product categories?
Okay, I asked the question and then immediately answered it myself. You can see in includes/fields/class-acf-field-taxonomy.php line 15 that the terms are saved to the post with a priority of 15. If you don’t specify the priority of your acf/save_post function, it defaults to 10, which will run before the terms save. The easy fix for me was the change my function priority to 20. Everything still works and now my terms are saving on new posts!
Would like to add that 4+ years later, this is still an issue. Same setup for me:
I mostly understand why this is happening. But to avoid needing to use wp_set_object_terms(), is it possible for me to use another acf filter that fires after the terms are normally saved to the post in order to finish off the redirect?

When template? It is the archive for the taxonomy or a specific term?
Hmm, so the code I provided works when I’m viewing that taxonomy archive (i.e. http://www.example.com/speakers/) but when I view a post type archive (i.e. http://www.example.com/category/) it doesn’t work.
I do have the Field Group set to show when that Taxonomy is set to Speakers… so how do I get them to display the values on other category/archive pages?

// get tax field without formatting, returns term if
$speakname= get_field('speaker_name', false, false);
// get field from term
$bio= get_field('speaker_bio', 'term_'.$speakname);
https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/

There has historically been a scaling issue when it comes to many of the relationship type fields. ACF is working within what is provided by WP. The taxonomy filter on the relationship field must get all of the taxonomies and then all of the terms in each taxonomy in order to sort them for the filter. This is also effected by the post types that can be filtered or the post type setting when filtering. This can be improved by limiting the post types and the taxonomies that appear in the filter. With a taxonomy with many terms in it has been reported that the request time out and showing no results. It may be necessary to limit the post types and not allow filtering by taxonomy on extremely large sites.
For more on this you should probably contact the developer here https://www.advancedcustomfields.com/contact/

$products = get_field('products_in_this_auction', false false);
$categories = get_terms('type_produc', 'orderby=count&order=DESC&hide_empty=1');
foreach( $categories as $category ):
?>
<h3 class="title_pru"><?php echo $category->name; // Prints the cat/taxonomy group title ?></h3>
<?php
$posts = get_posts(array(
'post__in' => $products,
'post_type' => 'myproduct',
'taxonomy' => $category->taxonomy,
'term' => $category->slug,
'nopaging' => true,
));
foreach($posts as $post):
setup_postdata($post);
?>
<div id="post-<?php the_ID(); ?>">
<?php the_title( sprintf( '<p class="title_pru"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></p>' ); ?>
</div><!-- #post-## -->
<?php endforeach; ?>
<?php endforeach; ?>
hi,
I’m sorry my friend, I don’t understand you.
Sorry I’m not that good with WordPress.
Should I manipulate the get_terms function with one of its many parameters?
I tried to follow you but it didn’t work.
$categories = get_terms( 'type_produc', array(
'orderby' => 'count',
'order'=>'DESC',
'hide_empty' => true,
'fields' => 'ids' // (or parent) but not found
) );
What you are telling me is that first I must save the posts that produce the code you gave me and then look for the taxonomy of each one?
Sorry I didn’t understand.
Thanks for your help and sorry for not understanding.
Hi,
Thank you very much for your help.
I have been able to solve a large part of the problem.
Thank you very much for responding so promptly.

The only problem with this solution is that WordPress shows me Taxonomies that have posts from other auctions.
While WordPress does not show empty taxonomies thanks to the ‘hide_empty’ rule hide_empty => true , it does show taxonomies that have a custom post type but belong to another auction.
Do you have any idea what I should change in the code below so that it only shows the taxonomies that are associated with the products of this auction?
Greetings and thank you very much for your help.
My code:
$products = get_field('products_in_this_auction', false, false);
$categories = get_terms( 'type_produc', array(
'orderby' => 'count',
'order'=>'DESC',
'hide_empty' => true
) );
foreach( $categories as $category ):
?>
<h3 class="title_pru"><?php echo $category->name; ?></h3>
<?php
$query = get_posts(array(
'post__in' => $products,
'post_type' => 'myproduct',
'taxonomy' => $category->taxonomy,
'term' => $category->slug,
'nopaging' => true,
));
foreach($query as $post):
setup_postdata($post);
?>
<div id="post-<?php the_ID(); ?>">
<?php the_title( sprintf( '<p class="title_pru"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></p>' ); ?>
</div><!-- #post-## -->
<?php endforeach; ?>
<?php endforeach; ?>

You need to add a posts__in argument that uses the post object field value.
// get the unformatted value of the field by setting
// third argument to false, returns array of posts IDs
$products = get_field('products_in_this_auction', false false);
$posts = get_posts(array(
'post__in' => $products,
'post_type' => 'myproduct',
'taxonomy' => $category->taxonomy,
'term' => $category->slug,
'nopaging' => true,
));
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.