Home Forums Front-end Issues Check post_objects against one another and only show one


Check post_objects against one another and only show one

  • Hi there!

    I have one post and one page:

    – Post: Member Profile – this displays post_objects and post_objects within flexible content.
    – Page: Meals to Print – this displays the post_objects and post_objects within flexible content from the post above.

    I have accomplished the above just fine, my issue is that the page stated above is for print only and I don’t want to show a post_object more than once.

    Because it isn’t a query (as it is getting the info from another post and from within different fields) I’m unsure as to how to tell my page:

    – once you’ve got all the post objects referenced from the post, check them and see if any are the same, if so only show one and ignore the others.

    I can create a flow diagram if needed?

    If this is at all possible, any help towards it is greatly appreciated 🙂

  • Hi @paxjah,

    Thanks for the post.

    You can achieve this through the acf/fields/post_object/query.

    With the use of this filter you can get the selected post objects from the first field and compare the values in the second one to make sure that they are unique.

    Another workaround would be to make use of the acf/validate_value filter to prevent the post from getting saved if the values on the second field are duplicated.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.