In the legacy (classic editor) it was possible to add buttons to the editor toolbar via tinymce API, that will add shortcode at cursor.

seems like this is not supported anymore from the tinymce FQA and this Gutenberg migration guide

Seems like it would be possible with the plugin tinymce advanced but I wonder what is today the best practice to add add a button to a tiny mce button to the the simple text editor of paragraph block.

The format API allows to add a custom format with tag and class around text, but does not to support adding string after text

Also, seems like this in the roadmap of the format API, but its not clear id its possible or not.

What is the best practice to add a button to tinymce editor tollbar in a simple paragraph block which will add text (shortcode for example) at cursor?

I added screenshot to clarify to which toolbar I refer.

Paragraph tinymce editor toolbar

  • You can add shortcodes via gutenberg shortcode block so what are you actually talking about? By the way due to Gutenberg it is now useless to add shortcodes in new code and I think that shortcode block is also just added for backward compatibility so if you are doing some thing new then I will recommend you to go for block. Commented Mar 11, 2019 at 21:25
  • 3
    I need to add the shortcode inline in editor, not as block
    – BenB
    Commented Mar 12, 2019 at 1:32
  • 1
    @MehmoodAhmad the shortcode block is not inline
    – BenB
    Commented Mar 12, 2019 at 1:38
  • You can play with CSS and make that inline. Commented Mar 12, 2019 at 5:09
  • @MehmoodAhmadn to hacky. Looking to do this correctly via the gutenberg API
    – BenB
    Commented Mar 12, 2019 at 23:20

2 Answers 2


They have actually fixed it so you can just add the shortcode within the paragraph content and it works.

As simple as

...However, when [expand tag="span" title="this trigger" targtag="span"]hidden content[/expand] is clicked…

That would be the contents of a paragraph block with inline shortcode. See this for more information.


you can do this with this filter :

function do_shortcode_in_gut($block_content, $block) {
    return do_shortcode($block_content);
add_filter( 'render_block', 'do_shortcode_in_gut', 99, 2 );

This filtering your block render and do shortcode.

This is my exemple with Date shortcode

You can see in this screenshot I use a date shortcode with attributes. And the result : enter image description here

  • This looks like it should work but I'm finding images in the shortcode are getting all converted to code. Anyone have a solution?
    – Space
    Commented Jun 30, 2022 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.