Forums
Forums / Fixing WordPress / wp_get_attachment_link custom filter
(@charl99cfc)
13 years, 2 months ago
Hi all
Trying to write a filter to add the #id the url, but cannot seem to get it to work…
function modify_attachment_link($markup, $id, $permalink) { return preg_replace('/^<a([^>]+)>(.*)$/', '<a\\1 href="' . $permalink . '='.$id.'">\\2', $markup, $id, $permalink); } add_filter( 'wp_get_attachment_link', 'modify_attachment_link', 10, 6 );
Any suggestions?
Kind regards
The topic ‘wp_get_attachment_link custom filter’ is closed to new replies.