Forums

add <p> tags to get_post() content (4 posts)

  1. Gabe462
    Member
    Posted 5 months ago #

    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()?

    tia,
    G462

  2. Gabe462
    Member
    Posted 5 months ago #

    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()?

    G462

  3. dazonic
    Member
    Posted 1 month ago #

    Use the wpautop() function.

    wpautop($post->post_content);

  4. oferwald
    Member
    Posted 1 week ago #

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

Reply

You must log in to post.

About this Topic