php – Adding caption to all images inside an article

Question

My client has decided he wants to add inside the article body, for each image, the caption below the img tag.

I know WordPress has this shortcode built in, but since there are more than 300 articles, it would take a lot of time.

test test

To recap, for each tag inside my article body, I want to return that tag and after that a paragraph tag which contains the caption of the image.

I found the wp_get_attachment_image() method but I can’t make the connections when trying to get the article body and filtering those images in order to add the paragraph tag after each image.

Thanks a lot in advance!

0
Andrei Zamfira 1 week 2023-05-25T07:56:01-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse