Created
October 25, 2019 09:14
-
-
Save duongthanhthai/4a0c9a20bf6c51ba252abd76b5dc1bd2 to your computer and use it in GitHub Desktop.
Add rel attribute to Wordpress galleries created with a shortcode so they use a lightbox (ColorBox used in example)
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('wp_get_attachment_link', 'cb_add_rel_attribute'); | |
function cb_add_rel_attribute($link) { | |
global $post; | |
return str_replace('<a href', '<a rel="lightbox" href', $link); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment