It will be interesting to add a small _blank edit link in the relationship field close to the items (see attachment).
Can I done this by myself without the need to update it each time ACF is updated ?
Thank you !
Any thought on this anyone?
I too would like this feature.
Hi
There’s filter on the relationship field that you can change how the title showed up.
https://www.advancedcustomfields.com/resources/acf-fields-relationship-result/
How the relationship field interface works is, it just copy the text from the left side to right side. So you’d need to do some css to hide the edit link on the left.
Here’s the filter code looks like:
add_filter('acf/fields/relationship/result', 'acf_append_edit_link_to_relationship_results', 10, 4);
function acf_append_edit_link_to_relationship_results($title, $post, $field, $post_id) {
$title .= sprintf('<a href="%s" target="_blank">%s</a>', get_edit_post_link($post_id), __('Edit'));
return $title;
}
Cheers. 😜
Thanks for the tip @gummiforweb – I noticed it should actually use get_edit_post_link($post->ID)
though as $post_id refers to the ID of the post you are currently editing (not the acf relationship post)
We have developed a plugin for this. Feel free to use it. It will soon find it’s way to Packagist too.
https://github.com/triggerfishab/edit-links-for-acf-relationship-field