What is the best way to enable nested shortcodes?
http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes Everything you need to know about nested shortcodes in WP
http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes Everything you need to know about nested shortcodes in WP
You can use almost every character. Just the character / is dangerous. Do not allow it. WordPress is using preg_quote to escape the shortcode name, but it doesn’t include its own regex delimiter / when doing that. So the shortcode will not be properly escaped and you get a PHP warning. Besides that, there are … Read more
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
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
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
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
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
You’re asking about X, but I’ll answer with Y. IMHO, there are too many exceptions to handle to grant another solution. SyntaxHighlighter Evolved has the following Pro Tip (strong, uppercase, in the original): TIP: Don’t use the Visual editor if you don’t want your code mangled. TinyMCE will “clean up” your HTML. Not only that, … Read more
I think, basically your question is, how to query posts of a custom post type in a shortcode. You should have a look into the WP_Query section of WordPress: https://codex.wordpress.org/Class_Reference/WP_Query In my example code I create a shortcode, which shows the title of the latest published posts of the type ‘my-custom-post-type’: <?php add_shortcode( ‘shortcodename’, ‘display_custom_post_type’ … Read more
The easiest way would be to replace $content = $toc . $content; with $content = str_replace( ‘[toc]’, $toc, $content ); This would do a search for the string [toc] and replace it with the table of contents. It might be more complicated due to how the plugin would work, but on paper it is simple.