Answer the question
In order to leave comments, you need to log in
How to add div before img in wordpress?
You need to add a div before (or after) every img on a certain page in wordpress (in the content part).
That is, through the standard loader, we insert images on the page, post and see:
<p>
<a href="#">
<img class="alignnone wp-image-74 size-full" src="#" alt="" width="300" height="449">
</a>
<a href="#">
<img class="alignnone wp-image-75 size-full" src="#" alt="" width="300" height="449">
</a>
</p>
<p>
<a href="#">
<img class="alignnone wp-image-74 size-full" src="#" alt="" width="300" height="449">
<div class="newdiv"></div>
</a>
<a href="#">
<img class="alignnone wp-image-75 size-full" src="#" alt="" width="300" height="449">
<div class="newdiv"></div>
</a>
</p>
Answer the question
In order to leave comments, you need to log in
You can set a filter on 'get_image_tag' and add the desired tag after the image in the function.
But it would be more correct to do as you were advised in another answer - to add this tag through js.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question