admin管理员组

文章数量:1431398

I have created an options page and have added wp-editor input in that. While rendering the output of that, it doesn't render the output of shortcodes added into it. It just renders shortcodes as text.

Could any one please suggest what I'm doing wrong? Here is the code that I am using to get the output:

echo stripslashes( html_entity_decode(get_option('home_header_description')

I have already tried wrapping it in do_shortcode(). But my shortcode is like:

[show_more more=Read_more less=Read_less]
Lorem ipsum.........
[/show_more]

It is basically used for hiding text at the intial load and displays the text when 'read more' is clicked then again hides the text when 'Read less' is clicked.

When using do_shortcode what it outputs is it just hides the text and then doesn't shows the text when read more is clicked.

I have created an options page and have added wp-editor input in that. While rendering the output of that, it doesn't render the output of shortcodes added into it. It just renders shortcodes as text.

Could any one please suggest what I'm doing wrong? Here is the code that I am using to get the output:

echo stripslashes( html_entity_decode(get_option('home_header_description')

I have already tried wrapping it in do_shortcode(). But my shortcode is like:

[show_more more=Read_more less=Read_less]
Lorem ipsum.........
[/show_more]

It is basically used for hiding text at the intial load and displays the text when 'read more' is clicked then again hides the text when 'Read less' is clicked.

When using do_shortcode what it outputs is it just hides the text and then doesn't shows the text when read more is clicked.

Share Improve this question edited Apr 19, 2019 at 14:51 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Apr 19, 2019 at 7:26 vipworksvipworks 731 silver badge9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You have to explicitly add shortcode evaluation to a text field for it to work. By default it is only defined for the_content and the_excerpt. If you look at the source of the first one you see this line:

$content = apply_filters( 'the_content', $content );

Among the default filters is this one:

add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop()

So, for shortcodes to work in your case, you will have to modify the part where the text is echoed, to apply a filter first. Then you make do_shortcode one of the filters applied.

本文标签: wpeditor not rendering the shortcode