The get_edit_bookmark_link WordPress PHP filter allows you to modify the bookmark edit link in WordPress.
Usage
add_filter('get_edit_bookmark_link', 'your_custom_function', 10, 2); function your_custom_function($location, $link_id) { // your custom code here return $location; }
Parameters
$location
(string) – The edit link to be filtered.$link_id
(int) – Bookmark ID to be edited.
More information
See WordPress Developer Resources: get_edit_bookmark_link
Examples
Add a custom query parameter to the edit link
Modify the edit link to include a custom query parameter, such as source
.
add_filter('get_edit_bookmark_link', 'add_custom_query_parameter', 10, 2); function add_custom_query_parameter($location, $link_id) { $location = add_query_arg('source', 'your_source', $location); return $location; }
Change the edit link to a custom URL
Replace the default edit link with a custom URL.
add_filter('get_edit_bookmark_link', 'change_edit_link_to_custom_url', 10, 2); function change_edit_link_to_custom_url($location, $link_id) { $location = 'https://yourwebsite.com/custom-url/'; return $location; }
Add a CSS class to the edit link
Add a custom CSS class to the edit link.
add_filter('get_edit_bookmark_link', 'add_css_class_to_edit_link', 10, 2); function add_css_class_to_edit_link($location, $link_id) { $location = str_replace('<a href=', '<a class="your-css-class" href=', $location); return $location; }
Add a custom attribute to the edit link
Add a custom attribute, such as data-id
, to the edit link.
add_filter('get_edit_bookmark_link', 'add_custom_attribute_to_edit_link', 10, 2); function add_custom_attribute_to_edit_link($location, $link_id) { $location = str_replace('<a href=', '<a data-id="' . $link_id . '" href=', $location); return $location; }
Change the edit link text
Change the text of the edit link to a custom value.
add_filter('get_edit_bookmark_link', 'change_edit_link_text', 10, 2); function change_edit_link_text($location, $link_id) { $location = preg_replace('/>(.*?)</', '>Custom Edit Text<', $location); return $location; }