This does seem like a common issue caused by the wpautop filter. Can you strip some newlines from your shortcode usage? For instance change
your text
[you-have-a-new-message]
more text
to
your text
[you-have-a-new-message]
more text
Markus,
Thanks for the reply. This is the only thing I have in page:
[you-have-a-new-message][bbp-forum-index]
I tried this plugin, and it worked at removing p and b, but it messed up the rest of the site:
https://ww.wp.xz.cn/support/plugin/toggle-wpautop
Would be great if I could remove wpautop just around those two shortcodes, but leave the rest of the site alone. No luck yet with this.
-
This reply was modified 8 years, 10 months ago by
andrew55.
I just ran some tests on this. Apparently, using two shortcodes chained as in your example produces the empty paragraph. It kind of looks like a wpautop bug. Anyway, putting the following in your theme’s functions.php should fix the issue:
function shortcode_empty_paragraph_fix( $content ) {
// define your shortcodes to filter, '' filters all shortcodes
$shortcodes = array( 'you-have-a-new-message', 'bbp-forum-index' );
foreach ( $shortcodes as $shortcode ) {
$array = array (
'<p>[' . $shortcode => '[' .$shortcode,
'<p>[/' . $shortcode => '[/' .$shortcode,
$shortcode . ']</p>' => $shortcode . ']',
$shortcode . ']<br />' => $shortcode . ']'
);
$content = strtr( $content, $array );
}
return $content;
}
add_filter( 'the_content', 'shortcode_empty_paragraph_fix' );
Adapted from https://ww.wp.xz.cn/plugins/shortcode-empty-paragraph-fix/
-
This reply was modified 8 years, 10 months ago by
Markus Echterhoff. Reason: fixed typo
Seems to work great. Thank you very much.
Just in case someone else needs this, there did seem to be minor typo in function (use message instead of medssage).
Thanks again!
You’re welcome. Thanks for pointing out the typo, it’s now fixed. 🙂