Created
November 16, 2018 03:24
-
-
Save fourthdimension/07db0aad969cf6b1e1f4b51676dfb3f2 to your computer and use it in GitHub Desktop.
Add edit link in ACF Relationship Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
get_edit_post_link($post->ID) since $post_id refers to the current post.