R
R
RusTorg2015-03-12 17:02:25
CMS
RusTorg, 2015-03-12 17:02:25

How to change the output of the html markup of a post in WordPress?

How do I make it so that, for example, in my wordpress theme, it is possible to wrap all the img from the post in a div or add an additional class to the element?
For example, wp displays the default post image in html like this:

<figure>

<a href="link_url"><img class="aligncenter" src="img_url" alt=""></a>

</figure>

And I need to add another class to the picture or wrap it in another element:
<div>

<a href="link_url"><img class="aligncenter my_class" src="img_url" alt=""></a>

</div>

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Villarou, 2015-03-13
@VirmarY

Hang a filter on the_content function. In the filter, replace the Wp markup with the one you need. Here is an example material

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question