use*_*735 0 php wordpress echo
我正在尝试使用jQuery Collapse-O-Matic插件为我的标题使用图像,但是我使用的是do_shortcode echo并且在如何在回声中添加回声时有点磕磕绊绊.我尝试了一些选项,包括Heredoc方法,但我不知道如何使用我的特定代码实现.
我在下面添加了我的代码,有人能指出我正确的方向吗?所有和任何帮助表示赞赏,谢谢!
<?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]'); ?>
Run Code Online (Sandbox Code Playgroud)
您无需echo在<img>标签内使用.返回的字符串get_template_directory_uri()将被连接.使用此代码:
<?php echo do_shortcode('[expand title="<img src=\''.get_template_directory_uri().'/img/schedule.png\' />"
Run Code Online (Sandbox Code Playgroud)
编辑:有关更多信息,请参阅手册中的字符串.在这种情况下,您可以将函数调用视为变量.你可以用这种方式编写代码:
$uri = get_template_directory_uri();
echo '<img src=\''.$uri.'/img/schedule.png\' />';
Run Code Online (Sandbox Code Playgroud)
但是,您可以直接在echo语句中调用函数,而不是使用变量.
echo '<img src=\''.get_template_directory_uri().'/img/schedule.png\' />';
Run Code Online (Sandbox Code Playgroud)
本声明可分为三个部分:
'<img src=\'':这是一个字符串文字.get_template_directory_uri():这是一个返回字符串的函数.'/img/schedule.png\' />':这是另一个字符串文字.点(.)将这三个部分连接成一个字符串,然后打印出来echo.请参阅字符串操作以获取更多详
| 归档时间: |
|
| 查看次数: |
1611 次 |
| 最近记录: |