• Resolved colorart

    (@colorart)


    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 https://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

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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 );

    Thread Starter colorart

    (@colorart)

    Thanks.. ??

    You’re welcome.. ??

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get_page/post and no paragraphs problem’ is closed to new replies.