0

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

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.

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.