• Hi,

    Here is an example of some simple html code:


    <p>[myshortcode]</p>
    <p>[myshortcode]</p>

    The outputs of the two shortcodes should be displayed on two separate lines in a browser as they are between separate <p> tags. However that is not happening. The outputs are shown on the same line.

    So, if the output of [myshortcode] is “test”, instead producing the expected output of:

    test
    test

    on two separate lines, it produces:

    test test

    on the same line.

    Why is this and is there a solution?

    I have tested this on a default WordPress installation with no additional plugins apart from the one producing the [myshortcode] output and using one of the standard Twenty* themes.

    Thank you in advance for any assistance.

Viewing 8 replies - 1 through 8 (of 8 total)
  • It would be a guess without the specifics of the plugin that generates the output,

    but
    1. it could be a missing tag in the output generated by the shortcode
    2. it could be ‘something’ changing the css of <p> (is the plugin is the only thing) into inline or inline block

    Thread Starter pawanahluwalia

    (@pawanahluwalia)

    It is definitely not the plugin. I have tried it with several plugins and even wrote a shortcode myself that simply outputs the word “test” with no additional code. I get the same result. Strangely, there is no problem with any other tag e.g.


    <h4>[myshortcode]</h4>
    <h4>[myshortcode]</h4>

    works perfectly fine.

    what is the html output of the section with the shortcodes in the browser?

    what shortcodes exactly are you using?
    what is the full code of the shortcode functions?

    Thread Starter pawanahluwalia

    (@pawanahluwalia)

    Here’s a simple shortcode I’ve tested it with:


    function TestShortcode( $atts ) {

    return 'test';

    }

    add_shortcode( 'myshortcode', 'TestShortcode' );

    Indeed it does…. just tested 5.6.1 twentytwenty gutenberg nothing else

    Thread Starter pawanahluwalia

    (@pawanahluwalia)

    Thanks for verifying.

    So, is this a bug? Is there a solution? Does it need to be reported somewhere?

    And in 5.6.2 and 5.7
    but if you put any character except a white space char between the <p> and shortcodes it behaves as expected.

    It used to be the other way round with wpautop adding unwanted <p> now itseems something is stripping adjacent <p>s

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Shortcodes in separate tags appear on same line in browser’ is closed to new replies.