Forums

[resolved] get_post HTML text formatting not 'saving' (3 posts)

  1. donderhaas
    Member
    Posted 1 year ago #

    Before I go into my problem I first need to ask does get_post use WordPress' html formatting through the WYSIWYG editor?

    On the front page of my template I am displaying a specific post based on it's ID. This specific post displays as it should on the front page but...

    When I add/edit a post/page through the WYSIWYG editor by hitting enter for paragraph formatting and press the publish button, it doesn't add the html formatting.

    When I go back and to add/edit post/page and manually enter the HTML formatting tags by using the html button and then press publish it saves my formatting correctly.

    Here is the code I am using to display the specific post/page based on it's ID:

    $queried_post = get_post(37);
    echo $queried_post->post_content;

    Alternatively, if there is a better way of displaying a specific post like this I am open to suggestions...

    Thanks!

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    echo $queried_post->post_content; does not output the usual 'html formatting';

    try and use:

    echo apply_filters('the_content', $queried_post->post_content);

    http://codex.wordpress.org/Function_Reference/apply_filters

    (this is basically how it is applied in the core code of the_content())

  3. donderhaas
    Member
    Posted 1 year ago #

    Thanks Alchymyth!

    It works perfectly :)

Topic Closed

This topic has been closed to new replies.

About this Topic