Frequent user of this amazing plugin here.
I am trying to create a recipe website. I have a custom post type “recipe” with custom taxonomy “ingredient” with terms such as “garlic”, “onion”, “salt”, “pepper”… etc.
I have created this ACF repeater field to house the ingredients with the following fields: 1) Quantity (ACF number field); 2) Serving Size (ACF text field); 3) Ingredient (ACF “ingredient” taxonomy field); in the hopes of outputting repeating rows in the format of <Quantity> <Serving Size> <Ingredient Taxonomy Term> like: 1 clove garlic, 1 tbsp onion, 2 strips bacon… etc
However I am having trouble outputting different taxonomies in each row. When I save the recipe post-type, everything resets to the first selected ingredient term. For example, if my first repeater row’s ingredient field was ‘garlic’ term, upon saving the recipe post-type, the other rows’ ingredient fields all change to ‘garlic’ term.
Is it actually possible to assign a unique term to each row? Is this only doable by using ACF Relationship or Post Object field only? If so then I’ll have to resign myself to creating a new post-type of “ingredient” then.
Thank you in advance.
Thank you John!
This does indeed save the taxonomy terms to each field!
However, I also found out that this does not make the recipe post-type “acknowledge” these terms tagged to the post, which is a function I wish to have as well. This is so that the recipe ingredients are terms which users can click to view more recipes with this particular ingredient.
Does that make sense? For example, if I have the ingredient “chicken” in my repeater taxonomy field, it will be automatically tagged in the recipe post-type as a “chicken” term.
You’re not going to be able to have both using a taxonomy field. The main reason for this is that you’re using a repeater so if you save and load the values each row in the sub field loads the terms and or save them, each changing the terms associated with the post.
To do what you want you’d be better off having another custom post type for ingredients and then using a relationship type field instead of the taxonomy field. Overall it will be a bit more complicated. Then users can pick an ingredient and see recipes associated with the ingredient.
If you want to do this you should look at http://www.advancedcustomfields.com/resources/querying-relationship-fields/
I’m building a site with the EXACT same requirements and came upon your post as I try to figure out the best way to be able to both order ingredients independently for each recipe AND have them work as custom taxonomies.
I’m curious if your solution worked well or if you would do it differently in ACF now?
You must be logged in to reply to this topic.
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!
© 2023 Advanced Custom Fields.