Hi all!
I will try to explain as much I can since english is not my langage 😛
I’ve 3 Custom Post
#1: Location: Title, Content, ShortName(ACF text), location_rel(ACF relationship with summit)
#2: Summit: Title, Content, location_rel(ACF relationship with location), hike_rel(ACF Relationship with Hike)
#3: Hike: Title, Content, Hike_rel(ACF Relationship with Summit)
I want to be able to see the summit and location of the summit when I choose one or many in the Hike relationship search box.
I’ve made several test and I only got error, I’m kinda desperate…
That’s what I got
add_filter('acf/fields/relationship/result/name=sommet_rel', 'id_relationship_result', 10, 4);
function id_relationship_result($title, $post, $field, $post_id){
$location = get_field('location', $post->ID);
// var_dump($location);
$title.= ', ' . $location->post_name;
// return
return $title;
}
The emplacement is good. It filter my list of summit and I i’v try with hard coded dummy value. Everything is fine. But when I try to get the location post title or location shortname field, it give me error “Attempt to read property “post_name” on array … “. I don’t know where to go with this.
Thanks you!