我正在尝试编写一个函数,该函数将使用从短代码发送的字符串(一旦工作,该字符串将是url),但它返回的只是函数中的默认值。
我的短代码是
[youtube thumb url videoUrl=“测试”]
我的功能如下:
add_shortcode(\'youtube-thumb-url\', \'get_youtube_thumb_url_func\');
function get_youtube_thumb_url_func($atts)
{
extract(shortcode_atts(array(
\'videoUrl\' => \'urlhere\',
), $atts));
return $videoUrl;
}
它没有返回“test”,而是返回“urlhere”。如果“urlhere”为空,则不返回任何内容。