如何在Wordpress的echo短代码中添加php echo
我试图使用jQuery Collapse-O-Matic插件为我的标题使用一个图像,但是我使用的是do_短代码echo,在如何在echo中添加echo方面遇到了一些障碍。我尝试了一些选项,包括herdeoc方法,但我不确定如何用我的特定代码实现 我已经在下面添加了代码,有人能给我指出正确的方向吗?非常感谢您的帮助,谢谢如何在Wordpress的echo短代码中添加php echo,php,wordpress,echo,Php,Wordpress,Echo,我试图使用jQuery Collapse-O-Matic插件为我的标题使用一个图像,但是我使用的是do_短代码echo,在如何在echo中添加echo方面遇到了一些障碍。我尝试了一些选项,包括herdeoc方法,但我不确定如何用我的特定代码实现 我已经在下面添加了代码,有人能给我指出正确的方向吗?非常感谢您的帮助,谢谢 <?php echo do_shortcode('[expand title="<img src='<?php echo get_template_direct
<?php echo do_shortcode('[expand title="<img src='<?php echo get_template_directory_uri(); ?>/img/schedule.png' />" trigpos="below"]this is content..this is content..this is content..this is content..this is content..this is content..this is content..this is content..this is content..this is content..this is content..[/expand]'); ?>
试试这个:
<?php echo do_shortcode('[expand title="<img src=\''. get_template_directory_uri() .'/img/schedule.png\' />" trigpos="below"]this is content..this is content..this is content..this is content..this is content..this is content..this is content..this is content..this is content..this is content..this is content..[/expand]'); ?>
您不需要在中使用echo
:这是一个字符串文本
get\u template\u directory\u uri()
:这是一个返回字符串的函数
'/img/schedule.png\'/>'
:这是另一个字符串文字
点(
)将这三个部分连接成一个字符串,然后由echo
打印。有关更多详细信息,请参阅。这是行不通的<代码>回波
立即执行输出。您可能会使用do_shortcode('.'.'.'获取模板\u director().'.'.'.''.')
。完全没有回声。只需调用函数并连接结果。太棒了,谢谢大家!我不得不删除图像后的第二个单引号,但这样做了!这只是“最小化”php的一种形式吗?我不是PHP专家,所以我非常感谢这里的帮助和自学!)太棒了,帮了大忙!谢谢你的教训,在这里学到了很多!
<?php echo do_shortcode('[expand title="<img src=\''.get_template_directory_uri().'/img/schedule.png\' />"
$uri = get_template_directory_uri();
echo '<img src=\''.$uri.'/img/schedule.png\' />';
echo '<img src=\''.get_template_directory_uri().'/img/schedule.png\' />';