Home › Forums › Feature Requests › relationshipfield with direct link to post › Reply To: relationshipfield with direct link to post
Hi @nicmare,
Have you tried using the acf/fields/relationship/result
filter to add the link to the post on the text that displays for each post.
The code is simple, it should be as follows:
add_filter('acf/fields/relationship/result', 'my_relationship_result', 10, 4);
function my_relationship_result( $result, $object, $field, $post ) {
$link = '<a href="'.get_permalink($object->ID).'"">Link text</a>';
$result = $result . ' ' . $link;
return $result;
}
Have a look at acf/fields/relationship/query for more information.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.