Forums

[resolved] Post_content with formatting (7 posts)

  1. boon_
    Member
    Posted 2 years ago #

    Simple really...

    Is there a way to use <?php echo $post->post_content; ?> so that it mimics <?php the_content(); ?> in the way it retains all the WYSIWYG formatting information (specifically, <p> tags)?

    Thanks

  2. boon_
    Member
    Posted 2 years ago #

    Found it..

    <?php echo apply_filters('the_content', $post->post_content); ?>

  3. charlieperrins
    Member
    Posted 2 years ago #

    Thanks for posting your solution there boon_ , you've just saved me some time!

  4. art3k
    Member
    Posted 2 years ago #

    to me too... thanks!

  5. renWeb
    Member
    Posted 2 years ago #

    ...and me - thanks!

  6. phunx
    Member
    Posted 2 years ago #

    Sorry for the bump!

    I'm using the post_content for my pages because I'm working with columns:

    <?php
    $page_columns = explode ("[--column--]", $post->post_content);
    print $page_columns[0];
    print '<div class="column first">';
    print $page_columns[1];
    print '</div>';
    print'<div class="column second">';
    print $page_columns[2];
    print '</div>';
    ?>

    But... when I'm using this, there will be no paragraph tags.
    How do I use the pasted code above in combination with the <?php echo apply_filters('the_content', $post->post_content); ?>?

    (sorry for my bad English)

  7. phunx
    Member
    Posted 2 years ago #

    Found it

    <?php
    $page_columns = explode ("[--column--]", $post->post_content);
    print apply_filters('the_content', $page_columns[0]);
    print '<div class="column first">';
    print apply_filters('the_content', $page_columns[1]);
    print '</div>';
    print'<div class="column second">';
    print apply_filters('the_content', $page_columns[2]);
    print '</div>';
    ?>

    Worked for me.

Topic Closed

This topic has been closed to new replies.

About this Topic