Dynamic Web Lab
Back to insights

Removing extra p and line breaks from shortcodes in WordPress

October 31, 20121 min read

Some time shortcodes add some some extra <p> and <br /> after of before post.This is happend because of the wpautop filter.

You can easily prevent this by changing the execution priority of wpautop filter.

Simply use this code on your theme functions.php

[php]
remove_filter( ‘the_content’, ‘wpautop’ );
add_filter( ‘the_content’, ‘wpautop’ , 12);[/php]

Writer

Dynamic Web Lab Editorial

We share how we design, engineer, and scale digital products across the GCC, Europe, and the US.

Share this article

Tags

wordpress

Need help implementing this?

We turn these playbooks into shipped features. Let us scope your roadmap and support your team.

Start a project conversation