Adding a “figure X.” (x = number) text to image captions

Question

I want to dynamically add the number of the displayed image in the post by the order it appears before the actual caption, for example, original post:

(Paragraph)
(Image, caption: Text)
(Paragraph)
(Image, caption: Text)

What I want:

(Paragraph)
(Image, caption: Figure 1. Text)
(Paragraph)
(Image, caption: Figure 2. Text)

Is there a hook I can use specifically for doing this? I can’t seem to find a decent solution apart from preg_replace ing HTML components of the post, and I’m sure there is a better option.

0
Johnny 4 weeks 2021-04-24T03:31:32-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse