Title: shortcode causes broken paragraphs
Last modified: September 3, 2023

---

# shortcode causes broken paragraphs

 *  [learningtechthings](https://wordpress.org/support/users/evermight/)
 * (@evermight)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcode-causes-broken-paragraphs/)
 * I’m learning how to use short codes but I don’t undrestand why WordPress keeps
   rendering broken paragraph tags.
 * I created a file called `wp-content/themes/twentytwentythree/templates/single.
   html` with the following content:
 *     ```wp-block-code
       <main class="wp-block-group" style="margin-top:var(--wp--preset--spacing--50)">
       <!-- wp:shortcode -->
       [wl_event_head]
   
       <!-- /wp:shortcode --> </main>
       ```
   
 * I then made a file called `wp-content/plugins/wl/wl.php` with the following contents:
 *     ```wp-block-code
       /*
        * Plugin Name: Hello
        * Description: World
        */
   
       function wl_event_head($att) {
         return '<section>
         <div>
           <h1>Hello WP</h1>
         </div>
       </section>';
       }
   
       add_shortcode('wl_event_head', 'wl_event_head');
       ```
   
 * When I go to my webpage in firefox and look View Source, I see this:
 *     ```wp-block-code
       <main class="wp-block-group" style="margin-top:var(--wp--preset--spacing--50)">
       <section>
       <div>
       <h1>Hello WP</h1>
       </p></div>
       </section>
   
       </main>
       ```
   
 * Why is there a closing `p` tag? I noticed that if I delete some spaces in my 
   return string for `function wl_event_head($att)`, then sometimes maybe the closing`
   p` tag goes away.
 * What am I doing wrong?
 * Note: I tried putting this code in my `wp-content/themes/twentytwentythree/functions.
   php`
 *     ```wp-block-code
       remove_filter( 'the_content', 'wpautop' );
       remove_filter( 'the_excerpt', 'wpautop' );
       ```
   
 * It did not fix the problem.
    -  This topic was modified 2 years, 9 months ago by [learningtechthings](https://wordpress.org/support/users/evermight/).

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

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcode-causes-broken-paragraphs/#post-17021798)
 * I can reproduce the problem. I have also tested it with a classic theme, where
   the additional element is not included. Therefore, I see a connection with the
   block editor. Even with the current version of the Gutenberg plugin, this is 
   not fixed.
 * My recommendation would therefore be that you report this to the Gutenberg team:
   [https://github.com/WordPress/gutenberg/issues](https://github.com/WordPress/gutenberg/issues)
 *  Thread Starter [learningtechthings](https://wordpress.org/support/users/evermight/)
 * (@evermight)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcode-causes-broken-paragraphs/#post-17022304)
 * Ok, i took your advice and posted the issue here:
 * [https://github.com/WordPress/gutenberg/issues/54136](https://github.com/WordPress/gutenberg/issues/54136)
 *  Thread Starter [learningtechthings](https://wordpress.org/support/users/evermight/)
 * (@evermight)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcode-causes-broken-paragraphs/#post-17024954)
 * And I posted a temporary solution to both these places:
   [https://github.com/WordPress/gutenberg/issues/54136](https://github.com/WordPress/gutenberg/issues/54136)
   [https://wordpress.stackexchange.com/questions/418464/shortcode-causes-broken-paragraph-tags/418491](https://wordpress.stackexchange.com/questions/418464/shortcode-causes-broken-paragraph-tags/418491)

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

The topic ‘shortcode causes broken paragraphs’ is closed to new replies.

## Tags

 * [wpautop](https://wordpress.org/support/topic-tag/wpautop/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [learningtechthings](https://wordpress.org/support/users/evermight/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/shortcode-causes-broken-paragraphs/#post-17024954)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
