Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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>

So I created 2 shortcodes:

[start_employee] - which contains <ul class="employee"> .. </ul>

[employee] - which contains content about the employee

And it should work like that:

[start_employee]
[employee img=".." name=".." description=".."] 
[employee img=".." name=".." description=".."] 
[/start_employee]

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>

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?

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
323 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...