I’m building a theme, but in order for it to work correctly, the admin is having to include a HTML markup inside the WYSIWUG editor (such as div
, li
, .classnames
, etc.). This to me is a bad idea.
Can I generate/append certain HTML elements depending on what they submit? For example, I would need the following to happen:
- Wrap all images in
li
tags - All paragraphs before an image, be wrapped in a
div
- All paragraphs after an image, be wrapped in another
div
Would this rely on PHP, jQuery, or does WordPress have a built in function for helping me with this?
I would not want to use jQuery for something like this because you can’t really assume that the user has JavaScript enabled.
Regarding the images, it looks like you can use the
image_send_to_editor
filter (see https://wordpress.stackexchange.com/questions/20998/automatically-wrap-post-image-in-div for details).