WordPress Plugin, get HTML post content

I am building a wordpress plugin, that acts when the admin saves a new post.
I need to get the content of that post and i am retrieving $_POST['content'] and $_POST['post_content'].
The problem here is that i only get the text inside that content, i need the html.

This way, if i was expecting something like <p>Lorem</p><p>ipsum</p><p>dolor</p>, I get Lorem ipsum dolor.

Read More

Can someone help me please?

Thanks

Related posts

Leave a Reply

3 comments

  1. Well, as @ChrisCarson points out, WordPress doesn’t store paragraph tags in the database by default.

    So, what I need to do, is parse the paragraphs myself using:

    $content = explode(PHP_EOL . PHP_EOL, $this->request['content']);
    $htmlcontent = '';
    foreach($content as $line){
        $htmlcontent .= '<p>' . str_replace(PHP_EOL, '<br />' , $line) . '</p>';
    }   
    

    thanks anyway

  2. WordPress doesn’t store paragraph tags in the database by default. Try this…

    $content = trim(stripslashes($_POST["post_content"]));
    $html = apply_filters("the_content", $content);