Relationship Post Object Filtering Issue
-
Hello, I created a Relational Post Object Filter so that I could show more information about a post in the selection via the admin. The post object is shared due to the custom field names for the relationship fields being the exact same. This is presenting me with a problem where it’s showing empty post object information on the other side of the relationship.
For example:
Home Listings – Shows a relationship post object field to select a community to associate the home listing.
Communities – Shows a relationship post object field to select a home listing to associate with the community.On the Communities post in the admin, the post object selection is showing unwanted filtered data.
How do I exclude the unwanted data from the filter on the the communities posts in the admin when they both share the same custom field relationship name in ACF Pro settings?
Here’s my code for the filter that works great on one-side of the relationship but I’m not sure how to get this to work so the Community select doesn’t show Home Listing Filtered info:
add_filter('acf/fields/relationship/result/name=show_as_community_model', function($title, $post, $field, $post_id) { $lot = get_field('lot', $post->ID); $sqft = get_field('sq_ft', $post->ID); $mls = get_field('mls', $post->ID); $price = get_field('price',$post->ID); $title .= ' ? Lot: ' . $lot . ' ? SqFt: ' . $sqft . ' ? MLS: ' . $mls . ' ? Price: ' . $price . ''; return $title; }, 10, 4);
`
- The topic ‘Relationship Post Object Filtering Issue’ is closed to new replies.