Home › Forums › ACF PRO › Select from and amend Taxonomy fields from Relationship or Post Object item
I wondered if there is a way to select a post using the Relationship or Post Object field types, then select from that post’s list of Taxonomies or even add an additional Taxonomy option?
I will have 2 Post Types:
Each project will have different creators attributed to it, and I would like to list their contribution as a Taxonomy.
Project 1 is connected to Creator 1 and they are credited as being a Director and Animator on this Project through the associated taxonomies.
This would populated both the Project and Creator page.
Is this possible?
You could create a Repeater field for your
Projects containing the following:
When editing the
Project you can then create a new Repeater item for each
Creator and assign it roles. The downside is that in the
Creator templates you would have to query
Projects in order to check what the
Creator at hand is involved with, which, depending on the scale of your website, could be rather expensive.
Thanks for your reply!
Would there be a way of updating the taxonomies for the Creator in the CMS / WP Admin at all?
That way we wouldn’t have to cross-reference in the Front End pages.
With a bit of work that could be done, I suppose. Actually, I was just about to look into that as well for a similar case, but have not come around to it yet.
The idea is to create a custom Text field for
Creator, that is hidden from the post edit screen by contradictory logic, such as: “Show only if another random field contains any value and contains no value at the same time.” Then we would hook into the post edit screen whenever a post is saved, check if it is a
Project, iterate the Repeater, fetch each
Creator mentioned, and save the data in the hidden field as JSON, so on the
Creator template it suffices to
get_field( 'hidden_text' ) and unpack the JSON without querying the
Project post type.
It would cause a bunch of additional database queries every time a post is saved, but that is trivial, especially if the alternatives are to either cause a bunch of additional database queries every time the front-end is called, or do it all manually and go insane.
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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.