• Resolved jeremyclose

    (@jeremyclose)


    Instead of using the standard Heading and Content sections of the accordion, I used the heading as normal, but in the content, I added other WP blocks. Everything seems to work as expected, but there is an extra empty P tag that I can’t delete. Accordions used with standard P blocks don’t have the extra P tag.

    It looks like it exists where the editor inserts the “Start writing…” dummy text. If I add a paragraph there, then delete it, it will clear the empty P tag.

    Not sure if this is something that can be fixed so it doesn’t happen, or just more informative for other users.

Viewing 1 replies (of 1 total)
  • Plugin Author philbuchanan

    (@philbuchanan)

    This seems to be a limitation with how Gutenberg works. If there is a dummy “Start writing…” block (especially within an InnerBlocks block, which this plugin uses to allow you to insert any blocks as content of the accordion) it inserts an empty <p></p> tag. The easiest way to fix this is to simply make sure you remove all “Start writing…” blocks from inside accordion items.

    In sites I build I usually fix this globally by filtering the_content to remove all empty <p></p> tags. See code block below. I don’t necessarily recommend this solution for everyone.

    
    /**
     * Fixes empty <p> tags showing in the output content.
     */
    function pb_the_content_empty_paragraphs_fix($content) {
    	return str_replace('<p></p>', '', $content);
    }
    add_filter('the_content', 'pb_the_content_empty_paragraphs_fix');
    
Viewing 1 replies (of 1 total)

The topic ‘Empty P tag at end of accordion’ is closed to new replies.