Shortcode adding p and br tags

Not sure if this will be helpful to anyone else but the cause of the issue was a custom formatter the theme had: function my_formatter($content) { $new_content=””; $pattern_full=”{(\[raw\].*?\[/raw\])}is”; $pattern_contents=”{\[raw\](.*?)\[/raw\]}is”; $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($pieces as $piece) { if (preg_match($pattern_contents, $piece, $matches)) { $new_content .= $matches[1]; } else { $new_content .= wptexturize(wpautop($piece)); } … Read more

Allowing shortcodes inside attributes

Sorry, brackets are still not allowed within shortcodes, as you can see in the Shortcode API. However it’s possible to use enclosing shortcodes which will allow to use brackets. Let me demonstrate this: Shortcode: [foo bar=”No brackets here!”]…use [brackets] here[/foo] You can add this kind of shortcode in your functions.php like this: add_shortcode( ‘foo’, ‘foo_shortcode’ … Read more

How to prevent newline from appearing in shortcode?

The <br> tag is coming from wpautop(), which is one of a number of display filters added to the content via wp-includes/default-filters.php: // Display filters add_filter( ‘the_content’, ‘wptexturize’ ); add_filter( ‘the_content’, ‘convert_smilies’, 20 ); add_filter( ‘the_content’, ‘wpautop’ ); add_filter( ‘the_content’, ‘shortcode_unautop’ ); add_filter( ‘the_content’, ‘prepend_attachment’ ); add_filter( ‘the_content’, ‘wp_make_content_images_responsive’ ); … // Shortcodes add_filter( ‘the_content’, … Read more

Add custom shortcode button to Editor

I found it, WordPress made changes and you can now add buttons through a simple API if( !function_exists(‘_add_my_quicktags’) ){ function _add_my_quicktags() { ?> <script type=”text/javascript”> /* Add custom Quicktag buttons to the editor WordPress ver. 3.3 and above only * * Params for this are: * string id Required. Button HTML ID * string display … Read more

TED talks shortcode not working

Unfortunately, this is going to be a problem for you. The [ted] shortcode is specific to WordPress.com – not to a self-hosted site where you installed the software yourself from WordPress.org. The only embeds that WordPress.org’s software supports by default are listed in the Codex: YouTube (only public videos and playlists – “unlisted” and “private” … Read more