Hi @aplusplus
May I ask why you have used a relationship field on a taxonomy to relate the taxonomy to a post?
The point of a taxonomy is that it can be easily related to a post by standard WP functionality. Perhaps you don’t need the relationship field at all?
That said, to write the code, you first need to explain on what template the code is to run. What is the current WP query on this template and what is the url to access it?
Hi Kyle,
I’ve been doing some work with this field type lately and have gotten to know how to work with it a little more. Can you give me a little more information on what you need to do? Fill out the scope a little bit?
Also, as a sidenote, you may already be on top of this, but you can format your var dumps so they’re easier to view:
$values = get_field('projects_category');
print '<pre>';
print_r( $values );
print '</pre>';
Thanks,
Jeff
There are multiple ways to do this. You could either create a custom taxonomy called something like “show_on_home” and then, just like a category, you would choose an option when publishing the post and the just add ‘show_on_home’ => ‘true’ to your query.
Or, if you really want to use ACF to do this, you could just use a conditional statement to hide some of them. Something like this:
if (get_field('show_on_home')) {
Put your loop here...
}
That is sort of inefficient though because your still loading the posts with the loop, and then just hiding them.
The better way to do it, although a bit more complex, is using meta_queries in your main query. I would start here to learn about those: http://codex.wordpress.org/Class_Reference/WP_Meta_Query
Hi @RodniD
Sorry, I can’t offer an ETA on this feature right now.
Thanks
E
Hello, I’m experiencing the same type of issue with a site I’m currently working on. It’s only happening with a single Category. It does happen to be the Category with the most amount of Advanced Custom Fields (35). The majority of them are Text with some each of Number, Radio Button, Select, Checkbox, & Post Object.
It just began all of a sudden after having been working and no new Plugins added. I had the system admin up the memory to 1GB for each process. If there’s anything else I can provide that would be helpful, I should be able to get any information.
The error log is showing the following (I’ve replaced the actual working domain with “domain.com”):
2013/10/11 13:48:47 [error] 55797#0: *135330 FastCGI sent in stderr: “PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4096 bytes) in /usr/local/www/domain.com/wp-includes/taxonomy.php on line 2777” while reading response header from upstream, client: 10.10.10.100, server: domain.com, request: “GET /wp-admin/post.php?post=135261&action=edit HTTP/1.0”, upstream: “fastcgi://unix:/var/run/php-fpm.sock:”, host: “domain.com”, referrer: “http://domain.com/dining-guide/135261/china-house-twain-harte/”
2013/10/11 13:48:54 [warn] 55797#0: *135657 an upstream response is buffered to a temporary file /var/tmp/nginx/fastcgi_temp/7/25/0000000257 while reading upstream, client: 10.10.10.100, server: domain.com, request: “GET /wp-admin/edit.php?s&post_status=all&post_type=post&action=-1&m=0&cat=128&paged=1&mode=list&action2=-1 HTTP/1.0”, upstream: “fastcgi://unix:/var/run/php-fpm.sock:”, host: “domain.com”, referrer: “http://domain.com/wp-admin/edit.php”
Alright! THanks a lot for your answer! (?)
sure. It might be worth adding it to the field types list (http://www.advancedcustomfields.com/resources/#field-types)?
Thanks @elliot
Hi @charlie
They are both very different. The core taxonomy field is much more stable, so continue to use it.
Thanks
E
thanks @elliot. the code above makes sense. I must say I’m confused about the taxonomy field. The documentation page (http://www.advancedcustomfields.com/resources/) doesn’t say anything about a built in taxonomy field AFAIK.
I haven’t installed the add-on so I presume I’m using the built in one. Are they more or less the same?
Hi @charlie
Answer provided on http://support.advancedcustomfields.com/forums/topic/taxonomy-field-filter-to-only-show-parents/
Compare $field[‘name’]
Hi @charlie
Are you sure you are using the taxonomy add-on? Or are you using the taxonomy field which is part of ACF v4?
To run the filter on your specific field, you will need to look at the $field parameter of the filer like so:
if( $field['name'] != 'my_specific_name' )
{
return $args;
}
Hi @dashaluna
I’m not 100% I understand your reply, but ye, you can select a different option on the taxonomy field for it to render as a single select field type such as radio or select
Thanks
E
Hi @hannyk
Is it possible that you have selected the ‘save / load from post’ option on the taxonomy sub field?
If so, you will not be able to save different values for each row, as the values will be saved / loaded to the actual post object.
To solve the issue, just untick that option to save as normal post meta data
Thanks
E
Thank you Elliot,
I realised that I used a custom way of creating a meta box for displaying available taxonomy terms – I was displaying it as bullet list (instead of native check list), so that only one option could be selected.
This broke AJAX for displaying ACF meta box when a specific taxonomy term is selected.
Is there a way to allow only one taxonomy term to be selected and display its ACF meta box dynamically?
Thank you in advance,
Dasha
Field Order
Field Label
Field Name
Field Type
1 Standard (javascript:;)
standard
Checkbox
2 Course Description (javascript:;)
course_description
Wysiwyg Editor
3 Learning Outcomes (javascript:;)
learning_outcomes
Repeater
4 Target Audiences (javascript:;)
target_audiences
Checkbox
5 Format (javascript:;)
format
Checkbox
6 Grades (javascript:;)
grades
Checkbox
7 Pre-Requisites (javascript:;)
prerequisites
Post Object
8 Recommended & Related Courses (javascript:;)
related_courses
Post Object
9 Next Steps (javascript:;)
next_steps
Post Object
10 Agenda (javascript:;)
downloads
Repeater
11 Recommended Resources (javascript:;)
resources
Repeater
12 Specials (javascript:;)
specials
Wysiwyg Editor
13 Item Number (javascript:;)
item_number
Number
14 Price (javascript:;)
price
Text
15
Text
Drag and drop to reorder
+ Add Field (javascript:;)
Location
Rules
Create a set of rules to determine which edit screens will use these advanced custom fields
Show this field group if
Post TypeLogged in User TypePagePage TypePage ParentPage TemplatePostPost CategoryPost FormatPost StatusPost TaxonomyAttachmentTermUser
is equal tois not equal to
postpagecoursewpcf7_contact_formslide
and (http://mathsolutions.com/wp-admin/post.php?post=2296&action=edit#)
or
Add rule group (http://mathsolutions.com/wp-admin/post.php?post=2296&action=edit#)
Options
Order No.
Field groups are created in order
from lowest to highest
Position
High (after title)
Normal (after content)
Side
Style
No Metabox
Standard Metabox
Hide on screen
Select items to hidethem from the edit screen
If multiple field groups appear on an edit screen, the first field group’s options will be used. (the one with the lowest order number)
Content Editor
Excerpt
Custom Fields
Discussion
Comments
Revisions
Slug
Author
Format
Featured Image
Categories
Tags
Send Trackbacks
Also,
It would be great if you could demonstrate how I can setup your scenario. Can it be replicated with the default post category taxonomy?
If so, can you explain what location rules / field groups / fields I need to setup and what actions I need to follow?
Thanks
E
Hi @wightfield
I’ve just been looking into a solution for this issue.
I installed WPSEO, and yes, could see the visual issue of the ACF fields being added to the WPSEO section.
I have updated the JS to append the fields above the WPSEO section, so it looks like it is part of WP again!
As for the title, I don’t think I’ll add this into the taxonomy section as the title looks quite out of place.
I have however, added this functionality to the user edit screen.
Hope that helps.
Thanks
E
Sorry I’m quite new to wordpress so maybe I don’t use the right words.
In my case I register 2 custom taxonomies by diong this:
register_taxonomy('genres_bdd', 'bdd',array('hierarchical' => false, 'label' => 'Genres', 'query_var' => true, 'rewrite' => true));
register_taxonomy('categories_bdd', 'bdd',array('hierarchical' => true, 'label' => 'Catégories', 'query_var' => true, 'rewrite' => true));
Let’s say that the taxonomy “Manga” in my location rule belongs to “categories_bdd”.
The taxonomy field in my field group populate with the value from the taxonomy “Genres”.
Then if I write a post with the taxonomy “Manga” my field group appears: normal.
But then if I check one value in the taxonomy field inside the field group, it hides.
Hi @dahousemix
What do you mean by “taxonomy group or tag. I suggest it search only for a tag change.”.
I don’t quite understand these terms.
Thanks
E
Hi @elliot,
Yes the taxonomy field is from the field group that has the location rule for ‘Manga’.
The thing is that the taxonomy field and the taxonomy location rule are different custom taxonomy tags but from the same taxonomy category.
I think that with checkbox, ACF looks for a change of taxonomy for the location rule regarless of the taxonomy group or tag. I suggest it search only for a tag change.
Hi @dashaluna
Yes, there are location rules for taxonomy.
This will allow you to create a Video and select a taxonomy (not sure what your taxonomy name is), and ACF will fetch any field groups with matching location rules given the taxonomy selection.
Thanks
E
Hi @dahousemix
Thanks for the detail and screenshot, very clear!
Is the taxonomy field within the field group that has the location rule for ‘Manga’?
Perhaps the issue is that when you trigger a change on the taxonomy checkbox field, ACF looks to see if the location rule matches and hides the field group?
Great. I got it working too.
Is there a way this can be applied only to 1 specific taxonomy field? I have a filter that’s useful for one taxonomy field but not something I’d want to apply to all my taxonomy fields.
I tried in my add_filter function using ‘acf/fields/taxonomy/wp_list_categories/name=XYZ’ but that didn’t work (the field just displayed all the categories)
Alternatively I just might not be understanding this correctly.
Thanks
Sorry, I’ll try to make it simple.
For example, I have a custom type post with 3 custom taxonomies.
I created a Field Group in ACF with the location rule to show up only if the first taxonomy is “Manga”. (see below)
Then I added a taxonomy field populated by another custom taxonomy and set the type to “checkbox”.
So now when I create or edit a custom post, I choose the taxonomy “Manga” so that my Field Group show up.
But after that, if I use the checkbox field, my Field Group just hides again.
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.