0

I need to make a shortcode button to TinyMCE editor which, in the moment i click it fills up the content part with HTML.

When i click on button i need something like:

<div> ... </div>

And not:

[div] ... [/div]

I made my shortcodes work but i need this too.

Any help?

  • 3
    Can you post your current code? – birgire May 17 '15 at 13:40
  • @birgire i cannot post here all the code from the function because its too long ... but it is something like function two_columns_shortcode( $atts) {return 'some html content'} – Pito Axiu May 17 '15 at 17:17
1

You can check this out - wpgallery plugin, this is how they do it for the [gallery] shortcode, basically parsing the shortcodes on the client-side, and replacing them back and forth as you click "Visual" or "Text".

Unless you are building a plugin, I would advise you to refrain from using shortcodes - use plain HTML, you'll have an easier time working with the DOM, and the article contents will be more or less portable across themes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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