Shortcode is being surrounded by p tags
-
Hi there
In a rather unsuccessful first dip into plugins, I decided to produce a very simple plugin that automatically wraps content into a container div and two further divs. I would then style these divs accordingly, and apply some jQuery trickery to them.
I have a container shortcode, inside which there are several sub-container shortcodes. My plugin php is as follows:
add_shortcode('jprfadecontainer', 'jpr_do_fader_container'); add_shortcode('jprfade', 'jpr_do_fader_imgs'); function jpr_do_fader_container($attr, $content = null) { $attr = shortcode_atts(array(), $attr); $output = "<div class=\"jpr-fader-container\">"; //$content = strip_tags($content, '<div><img><a>'); $output .= "<div class=\"jpr-fader-content\">\n"; // global variable for width? $output .= do_shortcode($content); $output .= "</div><!-- End fader-content -->"; $output .= "</div><!-- End gallery container -->"; return $output; } function jpr_do_fader_subs($attr, $content = null) { $attr = shortcode_atts(array(), $attr); $output = "<div>" . $content ."</div>"; return $output; }
Totally simple, but enough to make things simple for the client to produce a cycling gallery of content.
The issue I am having is that the sub-shortcodes are being surrounded by p tags, so there is nasty HTML all over the place. My research has led me to think that it’s something to do with the wpautop function, but I’m also thinking it’s probably something I have omitted.
The source of the output (relevant from lines 58-64 of the source) can be found at https://children.jewellparkerrhodes.com/jpr_children_wp/books/ninth-ward/the-real-9th-ward/.
Any advice gratefully received…
J
- The topic ‘Shortcode is being surrounded by p tags’ is closed to new replies.