WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. colorart
    Member
    Posted 4 years ago #

    Hi.

    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:

    <?php
    $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?

    Thx

  2. Mark / t31os
    Moderator
    Posted 4 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
    Member
    Posted 4 years ago #

    Thanks.. :)

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    You're welcome.. :)

  5. adamknox
    Member
    Posted 3 years ago #

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

    <?php
    $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