Wordpress-Gutenberg-短代码未呈现

Wordpress-Gutenberg-短代码未呈现,wordpress,shortcode,wordpress-gutenberg,Wordpress,Shortcode,Wordpress Gutenberg,我打开了古腾堡,试图在页面上创建一个短代码。这是我在functions.php中的代码 //在文本区域中启用短代码 添加过滤器('widget_text','shortcode_top'); 添加_过滤器('widget_text','do_shortcode'); //启用短代码 添加过滤器('the_摘录','shortcode'u顶部'); 添加_过滤器('the_摘录','do_短代码'); 函数first_shortcode(){ $content='这是我的第一个短代码'; 返回$

我打开了古腾堡,试图在页面上创建一个短代码。这是我在functions.php中的代码

//在文本区域中启用短代码
添加过滤器('widget_text','shortcode_top');
添加_过滤器('widget_text','do_shortcode');
//启用短代码
添加过滤器('the_摘录','shortcode'u顶部');
添加_过滤器('the_摘录','do_短代码');
函数first_shortcode(){
$content='这是我的第一个短代码';
返回$content;
}

添加动作(“我的快捷码”,“第一个快捷码”)您使用了错误的函数来生成短代码

使用
add_shortcode
创建短代码,而不是
add_action

请使用此代码

function first_shortcode() { 
  $content = '<h1>This is my first shortcode</h1>';
  return $content;
}
add_shortcode('my_shortcode', 'first_shortcode');
function first_shortcode(){
$content='这是我的第一个短代码';
返回$content;
}
添加_短码(“我的_短码”、“第一个_短码”);

您使用了错误的函数来生成短代码

使用
add_shortcode
创建短代码,而不是
add_action

请使用此代码

function first_shortcode() { 
  $content = '<h1>This is my first shortcode</h1>';
  return $content;
}
add_shortcode('my_shortcode', 'first_shortcode');
function first_shortcode(){
$content='这是我的第一个短代码';
返回$content;
}
添加_短码(“我的_短码”、“第一个_短码”);