I was working on a WordPress plugin, and I found that when the_content filter hook is used, it gives content of the post to the function as a parameter, but in plain-text format. I want to get the HTML content of the post, any way to achieve this?
Thanks
– Kapeel
Finally, after searching a lot, I had solved it.
As said by TheDeadMedic – “Are you sure that the post content does actually contain HTML? Don’t forget WordPress will add paragraphs on-the-fly, and won’t necessarily store them in the DB.”
WordPress does by using a function called
wpautop();I just used this with
get_the_content();, and I got it working.Here’s an example of how you can achieve this –
EDIT :
I found that this function won’t apply filters by other plugins. The following function won’t cause any issues.