Skip to content

Instantly share code, notes, and snippets.

@fourthdimension
Created November 16, 2018 03:24
Show Gist options
  • Save fourthdimension/07db0aad969cf6b1e1f4b51676dfb3f2 to your computer and use it in GitHub Desktop.
Save fourthdimension/07db0aad969cf6b1e1f4b51676dfb3f2 to your computer and use it in GitHub Desktop.
Add edit link in ACF Relationship Field
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')) . $title;
return $title;
}
@pixelmultiplo
Copy link

Use
get_edit_post_link($post->ID) since $post_id refers to the current post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment