Title: shortcode block and line breaks
Last modified: May 5, 2026

---

# shortcode block and line breaks

 *  Resolved [hupe13](https://wordpress.org/support/users/hupe13/)
 * (@hupe13)
 * [1 week, 2 days ago](https://wordpress.org/support/topic/shortcode-block-and-line-breaks/)
 * If you write multiple shortcodes in a shortcode block, each on a new line, line
   breaks `<br />` and paragraphs `<p>` `</p>` are inserted during rendering. This
   can result in large gaps.
 * Is this a feature or a bug?
 * There is an shortcode_unautop function for removing `<p>` `</p>`, but that didn’t
   help in my case. I solved this in my plugin with some [code](https://plugins.trac.wordpress.org/browser/extensions-leaflet-map/tags/5.0/php/enqueue-leafletplugins.php#L657).
 * Or is there another solution that works for everyone?
    -  This topic was modified 1 week, 2 days ago by [hupe13](https://wordpress.org/support/users/hupe13/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 week, 1 day ago](https://wordpress.org/support/topic/shortcode-block-and-line-breaks/#post-18900039)
 * I can’t reproduce the issue you described. Here’s what I did to test it:
 * A completely new WordPress installation (version 6.9.4).
 * The default TwentyTwentyFive theme.
 * Two custom shortcodes:
 *     ```wp-block-code
       add_shortcode( 'example1', function( $atts ) {    return 'example1out';} );add_shortcode( 'example2', function( $atts ) {    return 'example2out';} );
       ```
   
 * I inserted this shortcode block into a page:
 *     ```wp-block-code
       <!-- wp:shortcode -->[example1][example2]<!-- /wp:shortcode -->
       ```
   
 * This is how it appears on the front end:
 *     ```wp-block-code
       <div class="entry-content alignfull wp-block-post-content has-global-padding is-layout-constrained wp-block-post-content-is-layout-constrained"><p>example1out<br />example2out</p></div>
       ```
   
 * In which environment and with which theme did you encounter this issue?
 *  Thread Starter [hupe13](https://wordpress.org/support/users/hupe13/)
 * (@hupe13)
 * [1 week, 1 day ago](https://wordpress.org/support/topic/shortcode-block-and-line-breaks/#post-18900355)
 * The problem is the `<br />`:
 *     ```wp-block-code
       example1out<br />
       ```
   
 * Maybe it is a [special case](https://de.wordpress.org/support/topic/riesiger-freiraum-nach-leaflet-map/#post-176014):
 * > If you enter the shortcodes individually, one per shortcode block, no `<br /
   > >` tags are generated. If you enter the shortcodes in a single shortcode block,
   > one per line, the `<br />` tags are inserted.
 * The shortcodes in the Leaflet Map plugins create mostly Javascript, the concrete
   shortcode creates no output, WordPress renders the shortcode block and adds the`
   <br />`.
 * Is that the intention?
 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 week, 1 day ago](https://wordpress.org/support/topic/shortcode-block-and-line-breaks/#post-18900478)
 * Am I understanding this correctly that in your case, one of the two shortcodes
   isn’t displaying anything at all? It might be helpful if you could provide a 
   specific example, like the one I demonstrated above. Which shortcodes are you
   using. What do they look like in the Block Editor, and how do they appear on 
   the front end.
 *  Thread Starter [hupe13](https://wordpress.org/support/users/hupe13/)
 * (@hupe13)
 * [1 week, 1 day ago](https://wordpress.org/support/topic/shortcode-block-and-line-breaks/#post-18900553)
 * No, no, it is correct, that the specific shortcode has no output.
 * Example: ids is the id of a picture in media gallery
 *     ```wp-block-code
       <!-- wp:shortcode -->[gallery ids=10518][gallery ids=10518][gallery ids=10518]<!-- /wp:shortcode --><!-- wp:paragraph --><p>*****</p><!-- /wp:paragraph --><!-- wp:shortcode -->[gallery ids=10518]<!-- /wp:shortcode --><!-- wp:shortcode -->[gallery ids=10518]<!-- /wp:shortcode --><!-- wp:shortcode -->[gallery ids=10518]<!-- /wp:shortcode -->
       ```
   
 * creates
 *     ```wp-block-code
       <p><div id='gallery-1' class='gallery galleryid-10950 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>			<div class='gallery-icon landscape'>				<a href='https://my-domain.tld/bild6/'><img decoding="async" width="150" height="150" src="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" srcset="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png 150w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6-300x300.png 300w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6.png 512w" sizes="(max-width: 150px) 100vw, 150px" /></a>			</div></figure>		</div><br /><div id='gallery-2' class='gallery galleryid-10950 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>			<div class='gallery-icon landscape'>				<a href='https://my-domain.tld/bild6/'><img decoding="async" width="150" height="150" src="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" srcset="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png 150w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6-300x300.png 300w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6.png 512w" sizes="(max-width: 150px) 100vw, 150px" /></a>			</div></figure>		</div><br /><div id='gallery-3' class='gallery galleryid-10950 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>			<div class='gallery-icon landscape'>				<a href='https://my-domain.tld/bild6/'><img decoding="async" width="150" height="150" src="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" srcset="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png 150w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6-300x300.png 300w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6.png 512w" sizes="(max-width: 150px) 100vw, 150px" /></a>			</div></figure>		</div></p><p>*****</p><div id='gallery-4' class='gallery galleryid-10950 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>			<div class='gallery-icon landscape'>				<a href='https://my-domain.tld/bild6/'><img decoding="async" width="150" height="150" src="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" srcset="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png 150w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6-300x300.png 300w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6.png 512w" sizes="(max-width: 150px) 100vw, 150px" /></a>			</div></figure>		</div><div id='gallery-5' class='gallery galleryid-10950 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>			<div class='gallery-icon landscape'>				<a href='https://my-domain.tld/bild6/'><img decoding="async" width="150" height="150" src="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" srcset="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png 150w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6-300x300.png 300w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6.png 512w" sizes="(max-width: 150px) 100vw, 150px" /></a>			</div></figure>		</div><div id='gallery-6' class='gallery galleryid-10950 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>			<div class='gallery-icon landscape'>				<a href='https://my-domain.tld/bild6/'><img decoding="async" width="150" height="150" src="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png" class="attachment-thumbnail size-thumbnail" alt="" srcset="https://my-domain.tld/wp-content/uploads/Bilder/Bild6-150x150.png 150w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6-300x300.png 300w, https://my-domain.tld/wp-content/uploads/Bilder/Bild6.png 512w" sizes="(max-width: 150px) 100vw, 150px" /></a>			</div></figure>		</div>
       ```
   
 * You can see the `<br />` . These generate a greater space between the pictures.
 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 week ago](https://wordpress.org/support/topic/shortcode-block-and-line-breaks/#post-18900992)
 * Yes, this HTML line break is correct here as well. In the shortcode block, you
   enter the individual shortcodes with a line break – which is then also applied
   in the output.
 * If you want to omit it, enter the shortcodes without a line break:
 *     ```wp-block-code
       <!-- wp:shortcode -->[gallery ids=10518][gallery ids=10518][gallery ids=10518]<!-- /wp:shortcode -->
       ```
   
 * Alternatively, you could also choose not to use shortcodes and use blocks instead.
   These ultimately offer the user more options as well.
 *  Thread Starter [hupe13](https://wordpress.org/support/users/hupe13/)
 * (@hupe13)
 * [1 week ago](https://wordpress.org/support/topic/shortcode-block-and-line-breaks/#post-18901028)
 * > Alternatively, you could also choose not to use shortcodes and use blocks instead.
 * That’s a big disadvantage of (my) Leaflet Map plugins, and it’s on the wish list.
   I’m not able to do that.

Viewing 6 replies - 1 through 6 (of 6 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fshortcode-block-and-line-breaks%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [hupe13](https://wordpress.org/support/users/hupe13/)
 * Last activity: [1 week ago](https://wordpress.org/support/topic/shortcode-block-and-line-breaks/#post-18901028)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
