我在努力输出
[embedyt]http://www.youtube.com/embed?layout=gallery&listType=playlist&list=*some-playlist*[/embedyt]通过在Wordpress中使用高级自定义字段和YouTube插件的组合。
我的代码是:
<?php
echo do_shortcode('[[embedyt]' . the_field('youtube-playlist') . '[/embedyt]]');
?>其中emedyt标记来自Embed和the_field(‘YouTube -播放列表’)来自高级自定义字段。
不幸的是,输出的内容是
http://www.youtube.com/embed?layout=gallery&listType=playlist&list=*some-test-playlist*[embedyt][/embedyt]我不明白我的PHP哪里出了问题,我有不同的变体,比如使用变量和不同类型的连接,但我显然遗漏了一些东西。
任何和所有的帮助都将不胜感激,谢谢!
发布于 2016-11-14 09:41:23
您正在调用the_field函数,它实际上打印自定义字段的值,但实际上需要将该值传递给do_shortcode函数,而不是显示它。
您必须使用get_field函数。尝试将您的代码更新为
<?php echo do_shortcode('[[embedyt]' . get_field('youtube-playlist') . '[/embedyt]]'); ?>https://stackoverflow.com/questions/40584407
复制相似问题