Home › Forums › Front-end Issues › Hide page's ACF oEmbed field if Post Object has value for different ACF oEmbed › Reply To: Hide page's ACF oEmbed field if Post Object has value for different ACF oEmbed
I don’t think you can do this just by localizing a script, and if you do then it would really only work after the post was saved. For example, if the post object field is empty then there would be no value. If the value in the post object changes then how would you change it? To localize the script you would need to include a list of every post that has a value in its oembed field.
This is like conditional logic, but conditional logic will not work across posts.
I know this is not the answer that you are looking for, but I would put in the field instructions for the home page oembed field that the video entered will only be used if the selected post does below does not have a video.
If I really needed to build this I would have to do an AJAX request based on the value in the post object field when that field is changed to see if the selected post has a value in the field and then depending on the response hide or show the other field by applying or removing the same class that ACF uses to hide fields based on conditional logic. I would also build an acf/prepare_field filter for the oembed field on the home page that would show or hide the field using the field rapper classes.
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!
© 2022 Advanced Custom Fields.