当我在页面上使用简码时效果很好,但在帖子中仅显示简码名称。 短代码示例:
function foobar_func( $atts ){
return "foo and bar";
}
add_shortcode( 'foobar', 'foobar_func' );
用法:
[foobar]
显示页面上
foo and bar
但仅在帖子上
[foobar]
我尝试了TwentySeventenn这样的基本主题,问题仍然存在。
答案 0 :(得分:1)
这很奇怪。因此,您将以上代码添加到了TwentySeventenn主题的functions.php中,但是在发布时不起作用?请仔细检查您是否在帖子内容文件中正确写入了[foobar]。 或者,如果您更改了主题,请检查是否使用the_content()而不是echo get_the_content();。 如果使用get_the_content(),则无法使用简码。