带参数的简码,但没有属性

Shortcode with parametar, but no attribute

标题可能听起来有点奇怪,抱歉。

我必须使用与此类似的简码(简体):

[name=John]

到return"Hi John".

我知道如果简码是

我会怎么做
[name first="John"]

但在我的第一个示例中,是否有可能以某种方式在代码中获取值 "John"?

我尝试使用

$a=shortcode_atts(array(
    'name'      => '',
), $atts);

但这没有用。

基于the documentation,你能做的最接近的事情是

// Usage [name]John[/name] will give: Hi John.
function name_shortcode( $atts, $content = null ) {
    return 'Hi '. $content .'.';
}
add_shortcode( 'name', 'name_shortcode' );

你可以有属性,但我认为这已经很接近你的意思了。