I have a problem with WP that need your help. Some of my posts have content that was applied “wp_autop” filters already. This filter turned all double break lines into <p>
tag. I want to the opposite thing: turn all <p>
tag into double break lines.
Do you have any suggestions? Thank you.
I just ran into this situation. Here is a function I used to undo wpautop. I might be missing something, but this is a good start:
I also needed a way to do this but wasn’t happy with any existing solutions so decided to make one. Hope it helps someone.
https://gist.github.com/fjarrett/ecddd0ed419bb853e390
Bonus: You could also potentially use this to determine if content has been altered by
wpautop
.The filter write not in the database, filter on frontend, when view the post or other content. You deactivate the filter and write a own filter for set your custom markup.
There’s a built in function in WordPress, but it’s JavaScript only triggered when you switch from Visual to HTML in the post editor (and it’s really buggy if html is actually used though). If its just normal post content (not html code) then you can just edit each post, switch the editor back and forth, then save.
This is probably the most labor intensive, but safest, way.