Support » Themes and Templates » add <p> tags to get_post() content

  • I thought that get_post() was failing to display the <p> tags of my pages, but then realized that the <p>’s aren’t stored in the text in the database anyway.

    On my page.php (copied from kubrick theme), the_content() adds <p> tags around paragraphs. How can I add <p> tags to my content that I’m retrieving using get_post()?


Viewing 4 replies - 1 through 4 (of 4 total)
  • I’m still trying to figure out how to parse get_post() output to add <p> tags around paragraphs. I’m reading about how using the $output parameter might help, but nothing’s clicked for me yet. Is there just another function I can parse the returned object with?

    It seems that my other option might be using wp_query() to (I’m not sure what yet). If I’m not going to be able to do this with get_post(), can someone point me to a resource on the intricacies of using wp_query()?


    Use the wpautop() function.


    I think this way is better
    $content = apply_filters(‘the_content’, $post->post_content);

    The WordPress wpautop filter changes BR and P tags as if the simple carriage return is banished to history. All through the night, I installed and uninstalled editors and plugins, and inserted code snippets.

    To force a line break, use the HTML editor and place this code at the end of the line. Probably unwittingly, wpautop ignores it:

    <br clear="none" />

    That’s pretty easy relief!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘add <p> tags to get_post() content’ is closed to new replies.