Created
January 23, 2022 10:29
-
-
Save ozkanozcan/76a1e1e993fc8a50af238f54ae258ac6 to your computer and use it in GitHub Desktop.
Convert Wordpress caption tag to html div tag
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
function convert_caption($content) | |
{ | |
return preg_replace( | |
'/\[caption([^\]]+)align="([^"]+)"\s+width="(\d+)"\](\s*\<img[^>]+>)\s*(.*?)\s*\[\/caption\]/i', | |
'<div\1style="width: \3px" class="wp-caption \2">\4<p class="caption">\5</p></div>', | |
$content); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment