在短代码函数中使用回声

时间:2012-12-18 09:35:11

标签: php wordpress

我正在使用Wordpress插件显示帖子标签的Google新闻Feed。

我正试着说:

<?php echo strip_tags(get_the_tag_list('','+','')); ?>

进入此echo的Google URI的单引号:

<?php echo do_shortcode( '[hungryfeed url="https://news.google.com/news/feeds?q='[[above function here]]'&output=rss" template="1" max_items="1"]' ); ?>

我不是特别擅长PHP;任何人都可以建议最好的方法吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

您需要将第一个代码存储到变量中,然后将变量放入url中。像这样的东西可能会起作用

<?php

$tags = strip_tags(get_the_tag_list('','+',''));
echo do_shortcode('[hungryfeed url="https://news.google.com/news/feeds?q='.$tags.'&output=rss" template="1" max_items="1"]');

?>
相关问题