I am wondering if there is a way to add div to specific elements in the WordPress page content?

For example, I would want to wrap a div around content starting at a H2 element and ending after an img element. The div should have custom classes assigned to them.

Is there anyway to do this? I don't want to have to hard-code the div so that other people can easily edit the page content.



1 Answer 1


I used JQuery to fix this problem and target the specific elements.

In particular, I used: wrap, wrapInner, wrapAll, replaceWith, unWrap, and remove.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.