Reputation: 506
I made a shortcode that returns a string, which is supposed to be displayed as html. The problem is that this string of html should also contain shortcodes to format the page. Meaning:
add_shortcode('my_shortcode','my_function');
function my_function(){
return ' [vc_column width="1/2"] <h1>This is my content between the shortcodes</h1> [/vc_column]';
}
How could i display this on a page? If i just add the [my_shortcode] in a shortcode block, it will display these returned shortcodes(vc_column) as a string, which is not what i need.
Upvotes: 0
Views: 1747
Reputation: 333
To display a short code using PHP you need to use the function do_shortcode
.
You need to do the following:
function my_function(){
return do_shortcode('[vc_column width="1/2"] <h1>This is my content between the shortcodes</h1> [/vc_column]');
}
Upvotes: 1