2

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

4

5 に答える 5

0

'the_content'にadd_filterを追加する場合は、おそらく

タグアウト:

http://codex.wordpress.org/Function_Reference/add_filter

于 2012-02-04T16:29:22.900 に答える
0

When in the "editor" switch to HTML mode from tinymce mode. That way it's not converting what you have in the textfield.

于 2012-02-04T18:46:49.270 に答える
0
      <?php remove_filter (‘the_content’, ‘wpautop’); ?>

http://codex.wordpress.org/Function_Reference/remove_filter

于 2012-02-05T01:56:55.337 に答える
0

Here is my solution:

the shortcode function returns

<div class="col a">'.preg_replace('#^<\/p>|<p>$#', '', do_shortcode($content)).'</div>

this removes all unwanted p tags

于 2012-02-07T09:56:18.630 に答える
0

This issue was fixed in Wordpress version 2.5.1 see the shortcode API for further details

于 2012-11-07T10:43:14.760 に答える