谁能告诉我,如何通过短代码显示图像。我的意思是,当我使用我的快捷码时,会显示一幅图像。(短代码示例:[smile]和图像位置mytemplate目录/图像/smile.png)很抱歉我的周英语。
如何通过快捷码显示图像
1 个回复
最合适的回答,由SO网友:ucon89 整理而成
这是创建短代码的基本函数。
将此代码放入函数中。php
function smile_shortcode() {
$output = get_template_directory_uri() . \'/images/smile.png\'; // put your smile image here
$_image = \'<img src="\' . $output . \'">\';
return $_image;
}
add_shortcode(\'smile\',\'smile_shortcode\');
然后转到仪表板和post editor。记住把[smile]
在你的岗位上。更多信息:http://codex.wordpress.org/Function_Reference/add_shortcode
结束