Sure thing, here you go: https://gist.github.com/wunderdojo/e0d5ef75dc76609f32de9eabc324306a
One key thing to note is that for my use case there is a custom post type called Products. Products have a custom taxonomy, Fee Type. Each product should only have a single fee type associated with it so in line 71 I’m using array_pop to grab the last value from the taxonomy array that ACF is returning.
In other words, ACF returns an array like ( 0=> , 1 => 8 ). In my use case there will only ever be a single taxonomy selected so I just grab the second (last) value in the array. If you allow multiple taxonomies you’d want to switch the comparison logic to use in_array() or keep it as is but loop through for each value in the array.
Same problem here, you just saved me big time. Upgraded from 4.5 to 5 and no fields showing, no prompt to upgrade the db. Thanks a ton for posting!
Gotcha, thanks for responding. If I get a free moment before you get a chance to do anything with it I’ll slap together a variation using slug and send you the code. In a dev -> staging -> production environment term ID is likely to get out of sync while term slug you have some degree of control over, espec. if you preface them in a consistent and unique way (ie: dojo-some-term-slug).
Cheers!
Plus 1 on this request. It wasn’t clear to me from the docs that the fields added via PHP wouldn’t show. I took it to mean that would only be the case if I specifically disabled the UI. Would be really helpful to have the option to show them.
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.