我有一个短代码,应该返回通过短代码传入的参数值。但是,它不是返回参数,而只是返回默认参数。
这是一个例子
//Returns store id
function getStore($atts){
extract(shortcode_atts(array(
'storeId' => 'defaultStore',
), $atts));
return $storeId;
}
add_shortcode('storeName', 'getStore');
然后我将以下短代码添加到帖子中。
[storeName storeId="another store name"]
但是,而不是看到以下字符串
another store name
我得到以下默认字符串
defaultStore
不确定我做错了什么。
所以看起来短代码属性必须全部小写。一旦我使用全部小写“storeid”而不是“storeId”一切正常。