[resolved] get_page/post and no paragraphs problem (5 posts)

  1. colorart
    Posted 6 years ago #


    I have a problem. I want to have 2 pages/posts on one front page in my wordpress.
    I add 2 pages on admin panel (id 53 , 57) and i edited index.php adding:

    $my_id = 53;
    $post_id_53 = get_post($my_id);
    $title = $post_id_53->post_title;
    $content = $post_id_53->post_content;
    echo $post_id_53->post_content;

    This works fine and i see the content of this post but there are NO paragraphs <p>.

    When i go to http://www.mydomain.com/53/ it looks ok. I cen write on admin using "enter" and this generate <p> tags. When i'm looking on my front page (in source) there are no <p> and this looks not ok. Any idea?


  2. Mark / t31os

    Posted 6 years ago #

    That's because the data has not run through any filters in that context..

    Try this..

    echo apply_filters( 'the_content' , $post_id_53->post_content );
  3. colorart
    Posted 6 years ago #

    Thanks.. :)

  4. Mark / t31os

    Posted 6 years ago #

    You're welcome.. :)

  5. adamknox
    Posted 5 years ago #

    I didn't really know how to apply that so after some fiddling here was what I ended up with:

    $page_id = 577;
    $page_data = get_page ( $page_id );
    $content = $page_data->post_content;
    $title = $page_data->post_title;
    echo '<h3>';
    echo $page_data->post_title;
    echo '</h3>';
    echo apply_filters( 'the_content', $page_data->post_content );

    Just to help out anyone else in the future

Topic Closed

This topic has been closed to new replies.

About this Topic