Support

Account

Home Forums General Issues No 'p' tags on WYSIWYG output when querying from different post

Solved

No 'p' tags on WYSIWYG output when querying from different post

  • Hi there!

    I have created a custom field with a WYSIWYG editor for a particular page that I also want to see in a different page. When I get_field() it in the post it was created the output is perfect, but when I try to pull it in from a different post the output has not a single <p>, which completely messes up my styles.

    Here’s what it looks like from the post it was generated:

    $field_dump = get_field('featured_show_content');
    var_dump($field_dump);

    produces the following output

    string '<h1>heading 1</h1>
    <h2>heading 2</h2>
    <h3>heading 3</h3>
    <h4>heading 4</h4>
    <pre>preformatted</pre>
    <p>This is the first paragraph of this wysiwyg test.</p>
    <p>This is the second paragraph of the wysiwyg test.</p>

    And when in a different post:

    $custom = get_post_custom(33);
    var_dump($custom);

    produces the following output

    'featured_show_content' => 
        array (size=1)
          0 => string '<h1>heading 1</h1>
    <h2>heading 2</h2>
    <h3>heading 3</h3>
    <h4>heading 4</h4>
    <pre>preformatted</pre>
    This is the first paragraph of this wysiwyg test.
    
    This is the second paragraph of the wysiwyg test.

    As you can see, there aren’t <p>s on the second case. Why does this happen? Is there a way around it? Any help would be much appreciated.

    Thanks!

  • I actually managed to solve it at the end.
    For some reason the way I was coding the call was only echoing content of the paragraphs. When I just simply did what is written in the documentation: get_field('key-of-the-field', ID-of-the-post);
    it pulled all the <p> tags…

    Box ticked! (and hopefully someone else will find this useful)

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘No 'p' tags on WYSIWYG output when querying from different post’ is closed to new replies.