I want to add the 'wp-caption' class to the figure element only if the image has caption. How do I do that? I'm using the new gutenberg enviroment, if that affects anything.

for example:

form this:

<figure class="alignleft"> <img src="#" alt="#"/> <figcaption>Test</figcaption> </figure>

to this:

<figure class="alignleft wp-caption"> <img src="#" alt="#"/> <figcaption>Test</figcaption> </figure>

so the wp-caption class was added to figure, because the image has caption.

Thank You

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.