Home › Forums › ACF PRO › Steve Jobs and Bill Gates – Relationship issue › Reply To: Steve Jobs and Bill Gates – Relationship issue
Hi @james,
thank you for oyur reply and helping me out.
I can some coding but I am not good at WP :/
I have added this code to the functions.php file:
function my_relationship_query( $args, $field, $post_id ) {
// only show children of the current post being edited
$args['post_parent'] = $post_id;
// return
return $args;
}
// filter for a specific field based on it's name
add_filter('acf/fields/relationship/query/name=report_relations', 'my_relationship_query', 10, 3);
Now I want the report_relations field to only show the following:
I have a post meta named “p2p_user_to_client_to”, the post_id in the postmeta table refers to the userID and the meta_value refers to a custom post type named “client”.
So basically I just want the the following in human language:
Get all the rows in the table for (Logged in user == postmeta.post_id)
AND
Get the custom post types WHERE post_type == client and post_type_id == (is whatever meta_value is for the found rows in the postmeta table).
I dont know really know how to imeplemtn this to the function above since I dont know how WP works.
If you can help me out I would be very very glad.
Thanks a lot for your help @James!
regards
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.