and in Shortcodes
-
Content in my shortcodes are getting wrapped in <p> or
by wpautop(). I’ve read in forums that putting shortcodes on their only lines should prevent this – but not so. I’ve tried it in the Visual Editor, the HTML editor, putting items on their own lines in various ways.I do not want to disable wpautop() as it comes in handy everywhere else for the end-user.
In my shortcode I want the author to be able to use headings and other rich text. This may be part of the issue (but shouldn’t be as far as I have read).
I’ve found complicated solutions like this: http://betterwp.net/17-protect-shortcodes-from-wpautop-and-the-likes/
And simpler solutions like adding the following to functions.php:
remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop' , 99); add_filter( 'the_content', 'shortcode_unautop',100 );Does anyone have a suggestion for the best way to hand this situation?
(Note: due to various reasons, I do not want the client writing the html that the shortcode creates).My shortcode example:
[col1] <h1>Heading</h1> Lorem ispum [/col1] function col1_shortcode($atts = null, $content = null){ $col = '<div class="col1">' . $content . '</div>'; return $col; }unwantedly returns empty <p>
<div class="col1"> <p></p> <h1>Heading</h1> <p>Lorem ispum</p> <p></p> </div>Thanks for the advise!
Brad
The topic ‘and in Shortcodes’ is closed to new replies.