
There have been other reports of taxonomy fields not loading and saving correctly. Most of the time it’s something to do with other plugins or a filter in place on the field. In one case the filter that was causing the issue had nothing to do with the taxonomy field (http://support.advancedcustomfields.com/forums/topic/okay-why-are-my-custom-taxonomies-not-saving-anymore/)
Try deactivating plugins and changing themes.
Thanks John,
What happened is that my taxonomy fields filled with all the taxonomy of the post.
For example, if i choose for TAXO FIELD1 the value “PLACE1” and for TAXO FIELD2 “PLACE2” it becomes :
TAXO FIELD1 -> “PLACE1” “PLACE2”
TAXO FIELD2 -> “PLACE1” “PLACE2”
If i uncheck value and save it stays like this.
If i uncheck LOAD TERMS it seems to work but i don’t know why ???
regards,

Yes, you can include a tax_query, or you can include category parameters in your query if you are using the standard categories taxonomy.
However, if you’re using a custom post type I would suggest that you also use a custom taxonomy. The reason is that WP does not know how to tell the difference between standard posts and a custom post type when showing post categories and your custom posts will probably appear on your category archive pages.
For category parameters: https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
For Tax Query: https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
Just want to go on record and point out that I experienced the same issue. All three filters:
acf/fields/taxonomy/query
acf/fields/taxonomy/query/name=
acf/fields/taxonomy/query/key=
fail to actually filter the taxonomy field query. This was tested in a functions.php file with plenty of other valid, working ACF customizations.
I’m a little late to this party but I was at my wits’ end figuring this out and managed to nail it.
I have a custom taxonomy called issue which has a custom field issue_date (date picker field). I wanted to add a custom column in the taxonomy edit screen to sort my issues by their dates. Here is what I came up with:
Step 1: Add the new Date column
function issue_columns($issue_columns) {
$issue_columns['date'] = 'Date';
return $issue_columns;
}
add_filter('manage_edit-issue_columns', 'issue_columns');
Step 2: Populate the new Date column
function manage_issue_columns($out, $column_name, $term_id) {
$issue = get_term($term_id, 'issue');
$date = DateTime::createFromFormat('Ymd', get_field('issue_date', $issue));
switch($column_name) {
case 'date':
$out = $date->format('Y/m/d');
break;
default:
break;
}
return $out;
}
add_filter('manage_issue_custom_column', 'manage_issue_columns', 10, 3);
Step 3: Make the new Date column sortable
function my_sortable_issue_column($columns) {
$columns['date'] = 'issue_date';
return $columns;
}
add_filter('manage_edit-issue_sortable_columns', 'my_sortable_issue_column');
Step 4: Define the custom sorting (where the magic happens)
function sort_issues_by_date_column($pieces, $tax, $args) {
global $pagenow;
if(!is_admin()) {
return;
}
if(is_admin() && $pagenow == 'edit-tags.php' && $tax[0] == 'issue' && (!isset($_GET['orderby']) || $_GET['orderby'] == 'issue_date')) {
$pieces['join'] .= " INNER JOIN wp_options AS opt ON opt.option_name = concat('issue_',t.term_id,'_issue_date')";
$pieces['orderby'] = "ORDER BY opt.option_value";
$pieces['order'] = isset($_GET['order']) ? $_GET['order'] : "DESC";
}
return $pieces;
}
add_filter('terms_clauses', 'sort_issues_by_date_column', 10, 3);
For reference, my date picker field setting returns the date in the format Ymd.
If anyone has any improvements or questions please let me know!

there is an error in my code
<?php
$args = array(
'taxonomy' => 'category',
'hide_empty' => 0
);
$c = get_categories($args);
$c_keep = array();
foreach($c as $cat){
if (get_field('isprofession', 'category_'.$cat->term_id)) {
$c_keep[] = $cat; // forgot [] here
}
}
foreach($c_keep as $cat){
echo $cat->name;
}
?>
is it a bug with taxonomy field ??
in 5.2.6 the option was SYNC TERMS no there’re LOAD TERMS SAVE TERMS

meta queries do not currently work on taxonomies in WP. There are plans to add termmeta, but that’s going to be a couple of updates out. Also, I don’t know what the developers plans are for ACF once it is implemented in WP core.
What you need to do is get all the categories and then loop through them and see which ones have the value you want.
<?php
$args = array(
'taxonomy' => 'category',
'hide_empty' => 0
);
$c = get_categories($args);
$c_keep = array();
foreach($c as $cat){
if (get_field('isprofession', 'category_'.$cat->term_id)) {
$c_keep = $cat;
}
}
foreach($c_keep as $cat){
echo $cat->name;
}
?>

I’ve been looking into this a bit since I commented in the other topic. I found an interesting topic on stackoverflow. They suggest using update_field() on the repeater, supplying an array of values instead of trying to add sub fields.
With this in mind I took a look at the documentation for update_field() http://www.advancedcustomfields.com/resources/update_field/. This is actually covered there, it says taxonomy, but it could be used on a post, taxonomy is just used so that the example has a duel purpose.
/*
* add a repeater row on a taxonomy!!!
*/
$field_key = "repeater_field";
$post_id = "event_123";
$value = get_field($field_key, $post_id);
$value[] = array("sub_field_1" => "Foo", "sub_field_2" => "Bar");
update_field( $field_key, $value, $post_id );

There is a filter in the relationship field that will allow this. There is a previous topic that covers how to use it, however, like the use in that topic it will not currently work unless you apply a similar has as the one I outlined in that post. Basically you can change the orderby to order by date but you’ll need to override the part of the ACF file that groups the posts by taxonomy.
http://support.advancedcustomfields.com/forums/topic/relationship-filter-query-by-page-template/

To give an idea on the first question, this would require using WP_Query and adding a meta_query and a tax_query.
$args = array(
'post_type' => 'cars',
'post_per_page' => 9,
'meta_query' => array(
'key' => 'brand',
'value' => $vehicle_brand
),
'tax_query' => array(
'taxonomy' => 'catetory',
'field' => 'name',
'terms' => array($vehicle_type),
'include_children' => false,
),
);
Hi John,
I get this error when using your code:
Warning: Invalid argument supplied for foreach() in ... on line 83
I used the name of my field: book_type where you used checkbox_field.
Does it matter that it is a field used on a custom taxonomy? Not on a post.
So I’ve come down to this essentially.
When updating an ACF taxonomy field with update_field( "field_ID", "", $post_id) in order to clear the field, it does NOT remove the taxonomy association in the wp_term_relationships table.
This is with the Field Type set to Taxonomy, and the following checked:
Save Terms: Yes
Load Terms: Yes
Is there a way to unset the taxonomy field association on update_field? Currently I know what field I want to update and the applicable taxonomy, so I can use wp_delete_object_term_relationship against the given $post_id, but it would be nice if update_field took care of this for me.

Is this on admin forms or front end forms? I’ve tried with both and everything seems to be working.
Have you tried all the usual suspects, deactivating other plugins, trying another theme, etc?
Could this have something to do with the taxonomy term split? Are the terms that are not saving properly named the same as terms in some other taxonomy like tags or categories?
John, thank you so much!
$tag_id was = $term_id
my bad for being unfamiliar with the proper terms.
I did prefix it with the $taxonomy_slug like you explained and now it works perfectly.

What is the taxonomy and what is in $tag_id;
The post id (where you have $tag_id) should be $taxonomy_slug.'_'.$term_id
This is what I get saved save the form
Array
(
[_acfnonce] =>
[_acfchanged] => 1
[acf] => Array
(
[field_55e95e746593e] => Sample Article
[field_55e95e8b6593f] => Array
(
[55f1131e17718] => Array
(
[acf_fc_layout] => 3_columns
[field_55ee67fc0ce35] => 3
[field_55ee68170ce36] => lorem ipsum
[field_55ee683b0ce37] => lorem ipsum
[field_55ee8f67a0990] => lorem ipsum
)
[55f1132e1771c] => Array
(
[acf_fc_layout] => full_column
[field_55ee687d0ce3a] => lorem ipsum
)
)
[field_55e95eb365940] => Array
(
[0] => 64
[1] => 63
)
[field_55ee8eb9f1c6d] =>
[field_55e95efb65941] =>
[field_55efc8e15d926] =>
)
)
field_55e95e746593e = Title (Text)
field_55e95e8b6593f = Content (Flexible Content)
55f112041f2e9 = ??
field_55ee67fc0ce35 = Select with 3 value
field_55ee68170ce36 = Column 1 (Wysiwyg Editor)
field_55ee683b0ce37 = Column 2 (Wysiwyg Editor)
field_55ee8f67a0990 = Column 3 (Wysiwyg Editor)
field_55ee687d0ce3a = Full Column (Wysiwyg Editor)
field_55e95eb365940 = Category (Taxonomy)
field_55ee8eb9f1c6d = Adding New Category (Text)
field_55e95efb65941 = Featured Image (image)
field_55efc8e15d926 = Anoter Content (Wysiwyg Editor) – This is the initial content field I used before using the Flexible Content
As mention earlier, my initial intention was to create something similar to the capability of Page Builder. The reason I need to use Page Builder because the site I am working on allowed registered user to submit article.
And I will like to avoid the registered user to access our back-end thus we use ACR PRO form. And Flexible Content is the closest I can get to Page Builder.
You mention this
flex content field will be in a nested field
. Perhaps you can assist me how am I going about to do it?
Great!
The below Solved my problem! Just one note, I had to change the last curly bracket to a bracket just above the Wp_Query. Not having a matching meta_key tripped me up for just a minute too, but temporarily eliminating the reordering proved the code is good! Thanks! This helps some of us continue to make a living! 🙂
The winning code:
<?php
$part_category = get_sub_field('part_category'); // This HAS to be a string value. Make sure that it's not an array or term object.
$args = array(
'post_type' => 'sweeps',
'posts_per_page' => -1, //fetches ALL posts without limit
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'category', // If you're using a custom taxonomy this needs to be changed
'terms' => array($part_category[0]),
'field' => 'term_id'
)
)
);
$catquery = new WP_Query($args);
?>

Hi @skasprick
Hm okay. I think you might have two different issues here:
1. Sometimes when changing the return value you need to resave the post/term/whatever for the changes to occur. If you initially had term object you might want to try resaving.
2. I’m fairly certain that when using the checkbox layout the return wont just be an ID integer but an array. Try this:
<?php
$part_category = get_sub_field('part_category'); // This HAS to be a string value. Make sure that it's not an array or term object.
$args = array(
'post_type' => 'sweeps',
'posts_per_page' => -1, //fetches ALL posts without limit
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_key' => 'weight_lbs',
'tax_query' => array(
array(
'taxonomy' => 'category', // If you're using a custom taxonomy this needs to be changed
'terms' => array($part_category[0]),
'field' => 'term_id'
)
)
);
$catquery = new WP_Query($args);
?>
Or possibly:
<?php
$part_category = get_sub_field('part_category'); // This HAS to be a string value. Make sure that it's not an array or term object.
$args = array(
'post_type' => 'sweeps',
'posts_per_page' => -1, //fetches ALL posts without limit
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_key' => 'weight_lbs',
'tax_query' => array(
array(
'taxonomy' => 'category', // If you're using a custom taxonomy this needs to be changed
'terms' => array($part_category[0]->term_id),
'field' => 'term_id'
)
)
);
$catquery = new WP_Query($args);
?>

Alright.
I think your main issue lies in the meta_key value. I sincerely hope that’s not the actual meta field name. These should only contain small letters, 0-9 and possibly _ or – for separation.
Have a look at this and see if there’s something needing change.. look at the comments I’ve put in.
<?php
$part_category = get_sub_field('part_category'); // This HAS to be a string value. Make sure that it's not an array or term object.
$args = array(
'post_type' => 'sweeps',
'posts_per_page' => -1, //fetches ALL posts without limit
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_key' => 'weight_lbs',
'tax_query' => array(
array(
'taxonomy' => 'category', // If you're using a custom taxonomy this needs to be changed
'terms' => array($part_category),
'field' => 'term_id'
)
}
);
$catquery = new WP_Query($args);
?>
Worked like a charm, thanks a lot!
here is my code for other people, with the same question, to reference
<?php $term = $wp_query->queried_object; ?>
<article <?php post_class(''); ?>>
<div class="entry-content">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="post-image">
<?php $magazineimage = wp_get_attachment_image_src(get_field('magazine_taxonomy_image', $term->taxonomy . '_' . $term->term_id), 'full'); ?>
<img src="<?php echo $magazineimage[0]; ?>" alt="<?php echo get_the_title(get_field('magazine_taxonomy_image')) ?>" class="placeholder" />
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-8">
<?php the_field('magazine_taxonomy_description', $term->taxonomy . '_' . $term->term_id); ?>
</div>
</div>
</div>
</article>

Please post code within code tags as it makes it so much easier to look at as well as copy etc.
Could you try this:
<?php $term = $wp_query->queried_object; ?>
<?php the_field('magazine_taxonomy_description', $term->taxonomy . '_' . $term->term_id); ?>

Your question got me to digging through the ACF code and testing.
Honestly, I can find this line in the acf code
add_action('wp_ajax_acf/fields/taxonomy/query', array($this, 'ajax_query'));
but I don’t see that this line is ever run. This makes me believe that something has changed since that documentation was written, that there is a bug, or that I’m missing something important.
The filters that are applied are when showing checkboxes are these lines in /fields/taxonomy.php line 691
// filter for 3rd party customization
$args = apply_filters('acf/fields/taxonomy/wp_list_categories', $args, $field);
$args = apply_filters('acf/fields/taxonomy/wp_list_categories/name=' . $field['_name'], $args, $field);
$args = apply_filters('acf/fields/taxonomy/wp_list_categories/key=' . $field['key'], $args, $field);
So I tried this and it worked.
function my_taxonomy_query( $args, $field) {
// modify args
//echo 'here'; die;
$args['orderby'] = 'count';
$args['order'] = 'ASC';
// return
return $args;
}
add_filter('acf/fields/taxonomy/wp_list_categories', 'my_taxonomy_query', 10, 2);
I’m going to mark this thread for the developer’s attention and maybe he’ll comment and let us know what’s going on.
I remove the is_admin() tag from the if & still got no reaction.
+ as test I put this in the functions.php file:
function my_taxonomy_query( $args, $field, $post_id ) {
// modify args
$args['orderby'] = 'count';
$args['order'] = 'ASC';
echo '<pre>';
print_r( $args );
echo '</pre>';
exit;
// return
return $args;
}
add_filter('acf/fields/taxonomy/query', 'my_taxonomy_query');
Is it possible the ajax call is never done because its a frontend form?
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.