短代码中的短代码 - wordpress [英] Shortcodes inside a shortcode - wordpress
问题描述
我创建了一个显示员工的短代码,HTML 看起来像这样:
I created a shortcode which display the employees, the HTML look somthing like that:
<ul class="employees">
<li><img src=""> <h5>name</h5> <p>description</p></li>
<li><img src=""> <h5>name</h5> <p>description</p></li>
..
</ul>
所以我创建了 2 个短代码:
So I created 2 shortcodes:
[start_employee] - 包含 .. </ul>
[start_employee] - which contains <ul class="employee"> .. </ul>
[employee] - 包含关于员工的内容
[employee] - which contains content about the employee
它应该是这样工作的:
[start_employee]
[employee img=".." name=".." description=".."]
[employee img=".." name=".." description=".."]
[/start_employee]
但是当我把它放在 wordpress 编辑器中时,html 看起来像这样:
but when I put it in the wordpress editor the html look like that:
<ul class="employee">
[employee img=".." name=".." description=".."]
[employee img=".." name=".." description=".."]
</ul>
我想我知道为什么..因为 start_employee 的功能包含:
I think I know why.. because the fuunction of start_employee contain:
return '<ul class="employee">'.$content.'</ul>';
我该怎么做才能把它读成简码?
What should I do that it read it as a shortcode?
谢谢.
推荐答案
短代码不会自动嵌套 -- 您必须自己调用 do_shortcode($content)
.请参阅 http://codex.wordpress.org/Shortcode_API 上的 caption_shortcode()
示例一>.
Shortcodes do not automatically nest -- you have to call do_shortcode($content)
yourself. See the caption_shortcode()
example on http://codex.wordpress.org/Shortcode_API.
这篇关于短代码中的短代码 - wordpress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!