Support » Fixing WordPress » Add shortcode to the editor

  • Hi,

    How can I add shortcodes to the editor?

    I know there are plugins for that, but I’m interested in the code level solution. Do you know any tutorial for that?


Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Tommy,

    Use the do_shortcode() function. For example, if your shortcode was [showsomethinghere id=”7″] you’d just do this:

    echo do_shortcode('[showsomethinghere id="7"]');

    If you want to track down what the actual shortcode does, find where whatever is generating it runs the add_shortcode() function.

    Hi Andrew,

    Thanks for the answer. Sorry I wasn’t clear. By “add to the editor” I meant how can I add a button to the editor that will insert my custom shortcode?

    Well, you can create a custom metabox that inserts things into the editor itself, which I haven’t done unfortunately. If i was trying to write a shortcode insert script, I’d probably go this route.

    Or you can reference this codex entry about adding buttons to TinyMCE:

    Let us know what you come up with and maybe we can help you troubleshoot.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add shortcode to the editor’ is closed to new replies.