Hi @colin
There are a few issues with your above code.
1. Misuse of the the_field function. This should be get_field.
2. The taxonomy field does have a drop-down (single select) mode
3. the param ‘cat’ expects an integer. If you selected checkbox for the field type, you will have an array of ids, not just one.
I would advise you to change the taxonomy field type to a single select, and then fix up the code from point 1.
Good luck
Cheers
E
Hi @MatsKruger
In both screenshots you have highlighted 2 completely different UI elements.
In the first screenshot, you have highlighted the native WP category box. Then in the popup, you have highlighted a text field.
Are you sure you are using ACF to create this taxonomy field?
Please see this article to load data from a term:
http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/
Thanks
E
If a ‘category’ is a standard WP taxonomy, then I don’t think this is an ACF question.
You should ask general WP questions on a WP forum such as stack overflow.
Thanks
E
Hello Elliot
Here is my code from the function.php
function create_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
‘name’ => __( ‘Tøjer’ ),
‘singular_name’ => __( ‘Tøj’ ),
);
$args = array(
‘hierarchical’ => true,
‘labels’ => $labels,
‘show_ui’ => true,
‘show_admin_column’ => true,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘toj’ ),
);
register_taxonomy( ‘toj’, array( ‘attachment’ ), $args );
}
And an image how it looks in media tab and an image how it looks i the gallery edit media popup
Hope it helps
Thanks
Hi @MatsKruger
Can you post a screenshot of the fieldgroup showing the field in question? What field type is it?
Thanks
E
Hi Elliot,
I had a go at the latest ACF. Results are mixed: checkboxes do now work, and previous information (stored with previous version of ACF) is retained between multi-select and the checkboxes. However – and this is possibly because I am using the taxonomy with images / attachments and not with posts (I didn’t test it with posts), this occurs: all the fields and their values are listed with no elaborate formatting, and then underneath they are listed again properly formatted with tabbing. Only changes made to the checkboxes in the second listing are retained on clicking ‘update’. I reverted back to the previous ACF and all is working – though only if using multi-select, as before.
Thanks for persisting with this.
Best, Peter
Hey, just wanted to let you know that this works great – was able to add this line:
$args['depth'] = 1;
to the filter function and only show the top level taxonomy terms in the edit screen
Hi @pfitz
Thanks for the info. I believe I have tracked down and solved the issue. You can download the latest ACF from github and test it out.
Let me know if it solves your issue
Cheers
E
Sorry i try again
I have made a custom taxonomy for my attacments, if i edit the attachments under media i will be presented with a list of checkboxes with the terms of the taxonomy.
Then i have used your plugin ACF with the Gallery addon for a post type i have called shops.
All my shops then have a gallery of products in their catalog but when they use the gallery plugin and click on the edit link on the image represented by af pencil it shows the taxonomy as a textbox.
I would like to have it not as a textbox but as list of checkboxes, radiobuttons or select list.
Because if they just use the textfield they dont get presented with any terms, so they need to know all the terms. This will make a mess in my filter function on the front end.
Hope it is easier to understand now
Thanks
Mats
Hi @rlocke
I think the issue is that the value ‘Cherry’ is not correct. ACF saves the term ID as the value, not the term name.
Changing this to the ID should work.
You can check your wp_postmeta for clarification on the value that is actually saved!
Thanks
E
Hi @jhkerschner
Thanks for the feedback,
I’ll do some testing for the taxonomy pages and conditional logic.
I have recently done some work to the conditional logic functionality. Can you try installing the latest ACF from github and test the issue again?
Thanks
E
Hi @MatsKruger
Sorry, I can’t understand your question.
It is very confusing. Can you re-write it being very clear about your issue?
Thanks
E
Hi @mcaus
It sounds like you want to create a product archive with categories.
I would do this:
1. Create a post type called ‘product’
2. Create a taxonomy called ‘product-category’ and connect it to ‘product’
3. Create a template file from the product archive ‘product-archive’ and create a custom loop that loops through all the categories. Each category should have a thumbnail which you can use ACF for
4. Create a template field for the taxonomy archive ‘taxonomy-product-category’ and allow this to loop through and render out the products in this category
5. Create a template for a sibgle product ‘single-product’ and this renders a single view. You can use ACF to populate field data for this product.
I don’t think you will need the options page for this.
Good luck
Cheers
E
Ok, it works that way:`
$fieldf = get_field_object('hair_color', $taxonomy . '_' . $term->term_id);
$field = get_field('hair_color', $taxonomy . '_' . $term->term_id);
$value = $fieldf['choices'][ $field ];
echo $value`
Thank you so much for your help
Hi @JiveDig
I would use WP taxonomies for this. A taxonomy is very light weight and can quickly be added / edited.
Create each song name / artist name as a taxonomy term (use 2 separate taxonomies)
In short, ACF won’t help you out much on this project. I would jump over to the stack exchange forum for nay further WP help
Good luck
Cheers
E
Thanks for the code snippets. Your code looks perfect so it must be 1 of 2 things:
1. You have a spelling mistake in your field_name ‘anuncio_pavilhao’
2. that you are using get_field in your functions.php file which at the moment ACF is not able to run correctly in.
Are either of these possible?
Thanks
E
Hi @Koko
Are you able to change this to useing a taxonomy for location?
This would make you life many times easier thanks to the native WP checkbox UI.
If this is not possible to change, you will have to create 2 select fields and populate them yourself using some kind of AJAX call to populate the second choice.
Sorry there is no easy way for this at the moment.
Thanks
E
When are you planning to add this feature to the plugin? I’d love to make use of it, and I’m kinda really needing it right now 😛
+1 for this feature to be added.
I’m looking to get a list of all Tags in a Relationship-style of field, where the chosen list of tags can then be reordered, as we can with Posts currently.
Like RichB, the Taxonomy checklist/multiple select only gets me half way there.
I’ve been playing with the code in the link you provided Elliot but I am not having much luck so far.
Fingers crossed this will be added soon!
Tested the current nightly build and the problem still occurs.
Hi @olethomas
Thanks for the bug report.
I’ll add this to the to-do but have a feeling I have fixed this issue in the current nightly build on github.
Are you able to test out this latest version?
Thanks
E
Hi @surfsup74
If the field is specific to the term, then you need to move the code WITHIN your terms loop and also use the $post_id parameter to target the taxonomy term.
You have done this correctly with the ‘term_thumbnail’ field, but for some reason, you have not followed this methodology with the ‘moduleclass’ field
It looks like you are using a text field for the hair_color field rather than a select/option field.
So try any of these:
<?php
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
$hair_color = get_field('hair_color', $taxonomy . '_' . $term_id);
echo $hair_color;
?>
<?php
global $post;
$taxonomy = "someting";
$terms = get_the_terms($post->ID, $taxonomy);
if( !empty($terms) )
{
$term = array_pop($terms);
$custom_field = get_field('hair_color', $taxonomy . '_' . $term->term_id );
// do something with $custom_field
}
?>
See this example for more info: http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/
If you do want to use a Radio Button field type and have them choose from a list of hair colors, then this might work too (I think):
<?php
$field = get_field_object('hair_color', $taxonomy . '_' . $term->term_id);
$value = get_field('hair_color');
$label = $field['choices'][ $value ];
echo '<p>' . $label . '</p>' ;
Probably didn’t work before due to being text field rather than select/radio field and the $taxonomy value not being defined, although not sure…
Looking at the PHP docs,
This is a function as of PHP 5.2.0
Perhaps you will need to upgrade the PHP version running on the server?
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.