我在我的主题中写了一个函数functions.php 我正在尝试注册add_shortcode() 像shown 在法典中:
<?php
/**
* theme\'s functions.php
*/
namespace MyNamespace;
//[foobar]
function foobar_func( $atts ){
return "foo and bar";
}
add_shortcode( \'foobar\', \'foobar_func\' );
然而,这不起作用,一篇包含
[foobar] 简单呈现;[foobar]”;作为文本,而不是被处理函数的返回值替换。
我猜这和我的functions.php 正在命名。是否需要执行一些特殊操作来引用add_shortcode?