Skip Navigation

[Resolved] ACF Taxonomy Term & Views

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 8.62 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by olegB-2 5 years, 2 months ago.

Assigned support staff: Beda.

Author
Posts
#408537

Hello!

Now Toolset supports taxonomy terms. However, the module Views supports only the custom fields for taxonomy terms that have been created using the Types. But why? Plugin Advansed Custom Fields also supports the creation of custom fields for taxonomy terms. Is it possible to achieve the display / filtering to these ACF fields in the Views?

#408653

Toolset Supports Taxonomy Terms since quite a while, if not years.

I assume you mean Term Meta (custom fields in taxonomies)

ACF has shown some conflicts with Toolset in many things.
It might be an incompatibility as Toolset basically lets you use also 3rd party Content.

We do not produce or support that Plugin and it might be a good idea to ask that Author how they store the Term Fields in the Database.

Meanwhile, can you also show me how you set things up?
I do not have Access to ACF and would need to see how and where those Fields are supposed to appear in a View.

For this you can provide me access and show me exactly where the issue appear, and maybe also show a Types Term Field that is working as you expect, so I can compare it.

#409165

OK, I see the issue.

Basically, those ACF Term Fields should be displayable with [wpv-taxonomy-field name='acf-taxonomy-field'].

But only if those are values stored as a string or a serialised array, and we do display the field content in any of those two cases.

We need to know how ACF Stores those values.

Please contact the Author of ACF and ask how the values are stored.

Maybe, ACF puts a prefix on fields, just as Types does? We use wpcf-field-slug
If this is the case, you would need to use the prefix in the ShortCode.

You might also install Adminer Plugin and check how the meta_value and meta_key are stored.
This will then enable me to tell you if it can be used or not with Types/Views.

As a general Thumb rule it's better to stick with one Plugin family and this would be in your case Toolset.
Types also has a single Text field for Terms.

It's not a good idea to mix plugins that do the same, on the same install.
ACF and Toolset present some still open conflicts.

#409439

I need ACF because Types is not the relationship fields.

ACF has no prefix. It stores the field as they are written. Show them you can use the shortcode: [acf field="fieldname"].

Views excellent displays ACF fields for the posts/custom post type and users.

#409584

I understand.

Please send me a Copy, updated and fresh downloaded, of ACF PRO, so I can test this and eventually report to the DEV Team.

You can use DropBox or Google Drive to share the Plugin with me.

If you want to spare the time, you can check where ACF stores that Field.
I suspect it's not in the proper DataBase Table but in a Custom table.

If so, Toolset can not access it.

#409630

This plugin is not handling things correctly, or I am very confused about it's usage.

See, when you set a Custom Field group for your Types, you can choose where it has to appear, right?
I wonder, since when a "Taxonomy" is "uncategorized", and a Taxonomy Term is "post_tag" or "category"

It's exactly opposite.

Besides that, even if I add a simple field with the Rule "Post Taxonomy" > "Uncategorized", I do not see that Field in my terms page.

I see it only when I choose "Forms" > Taxonomy Terms > Category.

Furthermore, the VALUE of that ACF Field is stored in the options table.
A Term Meta fied value is to be stored in the termmeta table (WordPress created this table especifically for this purpose) and that is what Types does, you can doublecheck my statements by looking at your Database.

If you are interested in the WP Core Code:
https://core.trac.wordpress.org/browser/tags/4.5.3/src/wp-admin/includes/schema.php#L60

This all above means, as long ACF is not storing this data in a accessbile Table, no plugin following the WordPress standards will be able to display them.

Please correct me if I am wrong.

#410716

Thank you for your help. ACF is really at the moment does not work correctly with the fields of taxonomy. However, developers are likely to fix this. It discusses the problem: hidden link. At the moment, you can use this code:

function acf_update_term_meta($value, $post_id, $field) {
	$term_id = intval(filter_var($post_id, FILTER_SANITIZE_NUMBER_INT));
	if($term_id > 0)
		update_term_meta($term_id, $field['name'], $value);
	return $value;
}
add_filter('acf/update_value/name=acf-taxonomy-field', 'acf_update_term_meta', 10, 3);

function acf_load_term_meta($value, $post_id, $field) {
	$term_id = intval(filter_var($post_id, FILTER_SANITIZE_NUMBER_INT));
	if($term_id > 0)
		$value = get_term_meta($term_id, $field['name'], true);
	return $value;
}
add_filter('acf/load_value/name=acf-taxonomy-field', 'acf_load_term_meta', 10, 3);

Using it, I got the display ACF fields for taxonomies using the Views. Everything works correctly!