I would like to insert some shortcodes in the wordpress editor (v 3.3+)
The string looks like
[a_col]<p>some text or other stuff</p>[/a_col]
which is fine but if i use this line in JS
tinyMCE.get('content').setContent(string);
my shortcodes get surrounded by p tags which looks like
<p>[a_col]</p><p>some text or other stuff</p><p>[/a_col]</p>
I really don’t like to touch native functions. Maybe there is a different solution to insert content
If you were to add_filter on ‘the_content’, you could probably parse the
tags out:
http://codex.wordpress.org/Function_Reference/add_filter
When in the “editor” switch to HTML mode from tinymce mode. That way it’s not converting what you have in the textfield.
http://codex.wordpress.org/Function_Reference/remove_filter
Here is my solution:
the shortcode function returns
this removes all unwanted p tags
This issue was fixed in WordPress version 2.5.1 see the shortcode API for further details