Add button to visual editor to create shortcode (7 posts)

  1. Jeremy Herve
    Posted 6 years ago #


    I don't find the solution to my problem anywhere, so I am asking here:
    I have a shortcode created in my theme through my functions.php, which I need to write down in the editor every time I want to use it. The format of the shortcode is [shortcodename url="http://www.blabla.com"]

    Instead of writing that down everytime, I would like to add a button in my visual editor, that would call a small pop up where I would fill the url, and the shortcode would be generated this way.

    Is that something possible? If yes, how do I do that?

    Thanks for your help!

  2. clarklab
    Posted 6 years ago #

    I've been Googling around for a solution to this very problem for almost an hour now. I've been able to add buttons to the HTML editor but I desperately need to be able to add it to the Visual editor (most of my authors use the visual editor). Anyone have any ideas?

  3. Mark / t31os

    Posted 6 years ago #

    What's wrong with the URL/Link button provided as standard, can you not simply select the text, click the link button, enter the URL, and you have your text linked...

    Is that not essentially the same thing, only difference being that one uses shortcode, the other does not... the end result is the same..

  4. clarklab
    Posted 6 years ago #

    well my shortcode happens to be a completely complex PHP function. I'm just in search of a way to make a button my authors can use on the Visual editor.

    I've found multiple ways to get custom buttons working when the author has the HTML editor open but once the visual editor (tinymce) is activated my buttons no longer work. any ideas?

  5. clarklab
    Posted 6 years ago #

    specifically I've got a function that accepts a youtube ID and spits out preformed embed for the desktop site but just a link to the video on the mobile site. I've also got a complex blockquote/cite/link layout I'd like the authors to use and think a button that drops in the code they need might help things along.

  6. Mark / t31os

    Posted 6 years ago #

    Open up tinymce advanced and see how they do it... (the additional buttons that is)..

    That's where i'd start... :)

  7. bhomatude
    Posted 6 years ago #

    I found a solution with this plugin:




    Name your button in the "caption" window and drop the shortcode (or anything else) into the "before" window. The button shows up in the HTML editor toolbar.

Topic Closed

This topic has been closed to new replies.

About this Topic