0
votes

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.

1
Your question is a bit unclear. Do you want the vc_column shortcode to process? Or do you want to literally output on the page what you are returning - meaning the user will see [vc_column width="1/2"] <h1>This is my content between the shortcodes</h1> [/vc_column]? - disinfor

1 Answers

1
votes

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]');
}