Wordpress短代码返回包含短代码的html字符串

Wordpress短代码返回包含短代码的html字符串,wordpress,wordpress-shortcode,Wordpress,Wordpress Shortcode,我制作了一个返回字符串的短代码,该字符串应该显示为html。问题是这个html字符串还应该包含用于格式化页面的短代码。 意思是: add_shortcode('my_shortcode','my_function'); 函数my_函数(){ 返回“[vc_column width=“1/2”]这是我在短代码[/vc_column]之间的内容”; } 我怎样才能在页面上显示它?如果我只是在短代码块中添加[my_shortcode],它会将返回的短代码(vc_列)显示为字符串,这不是我需要的。要使

我制作了一个返回字符串的短代码,该字符串应该显示为html。问题是这个html字符串还应该包含用于格式化页面的短代码。 意思是:

add_shortcode('my_shortcode','my_function');
函数my_函数(){
返回“[vc_column width=“1/2”]这是我在短代码[/vc_column]之间的内容”;
}

我怎样才能在页面上显示它?如果我只是在短代码块中添加[my_shortcode],它会将返回的短代码(vc_列)显示为字符串,这不是我需要的。

要使用PHP显示短代码,需要使用函数
do_shortcode

您需要执行以下操作:

function my_function(){
    return do_shortcode('[vc_column width="1/2"] <h1>This is my content between the shortcodes</h1> [/vc_column]');
}
函数我的函数(){
返回do_短代码(“[vc_column width=“1/2”]这是我在短代码之间的内容[/vc_column]”);
}

您的问题有点不清楚。是否要处理
vc\u列
shortcode?或者您想在页面上直接输出您返回的内容吗?这意味着用户将看到
[vc\u column width=“1/2”]这是我在短代码[/vc\u column]之间的内容
function my_function(){
    return do_shortcode('[vc_column width="1/2"] <h1>This is my content between the shortcodes</h1> [/vc_column]');
}