Support

Account

Home Forums Front-end Issues Content not wrapped in the container paragraph

Solved

Content not wrapped in the container paragraph

  • Hi all!

    I’ve got a problema with the frontend output of a Wysiwyg field.

    Here’s my code:

    <p class="paragraph-container">
    <?php echo get_field('myfield', false, true); ?>
    </p>

    I would expect an output like:

    <p class="paragraph-container">
    <p> First line of my content</p>
    <p> Second line of my content </p>
    </p>
    

    Instead I get:

    <p class="paragraph-container"></p>
    <p> First line of my content</p>
    <p> Second line of my content </p>
    

    Any hint?

    Thanks in advance!

    Davide

  • Are you seeing this the inspector or the actual source code of the page?

    <p> elements cannot be nested, so you can’t use a paragraph as a container for other paragraphs. The browser assumes a </p> before the next open <p>.

    You need to use a div or some other type of block element as your container.

  • Oooooops!

    Sorry, this is an EPIC FAIL from me, I always forget that <p> aren’t nestable….

    Thanks!

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

The topic ‘Content not wrapped in the container paragraph’ is closed to new replies.