Home Forums Feature Requests Add edit link in relationship field


Add edit link in relationship field

    • will83

    • March 24, 2014 at 8:06 pm

    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 !

    • circuuz

    • November 17, 2017 at 1:02 am

    Any thought on this anyone?

    I too would like this feature.

    • gummi

    • November 24, 2017 at 6:09 pm


    There’s filter on the relationship field that you can change how the title showed up.

    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)

    • circuuz

    • March 18, 2020 at 7:18 pm

    We have developed a plugin for this. Feel free to use it. It will soon find it’s way to Packagist too.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

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.