为什么?do_shortcode
在休息通话中不起作用?
在下面的示例中,do_shortcode
存在,但不会解释短代码。
路线声明
/*
Adding a route with callback is interpret_shortcode function
*/
add_action( \'rest_api_init\', function ()
{
register_rest_route(
\'test\',
\'/someContent\',
array(
\'methods\' => \'GET\',
\'callback\' => \'interpret_shortcode\'
)
);
} );
短码调用
function interpret_shortcode( $data )
{
$content;
if ( function_exists( \'do_shortcode\' ) )
{
$content = do_shortcode("[et_pb_text] abc [/et_pb_text]");
}
else {
$content = "do_shortcode is missing";
}
return array(\'content\'=>$content); //Output "[et_pb_text] abc [/et_pb_text]"
}
在休息通话中,我们的情况是否与所描述的情况相同here 关于Ajax请求?