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.
1 Answer
Reset to default 1You 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
版权声明:本文标题:wp_editor not rendering the shortcode 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745572584a2664135.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论