您好,我正在使用以下短代码生成一个列表
[ul style="5"]
[li]Surgical Internship: Yale University – New Haven, Connecticut, 2001 [/li]
[li]Orthopaedic Residency: Yale University – New Haven, Connecticut, 2005[/li]
[li]Spine Fellowship: SpineCare, San Francisco Spine Institute – San Francisco, California, 2006[/li]
[/ul]
我希望其HTML生成如下:
<ul class="cg_style">
<li>Surgical Internship: Yale University – New Haven, Connecticut, 2001 </li>
<li]Orthopaedic Residency: Yale University – New Haven, Connecticut, 2005</li>
<li]Spine Fellowship: SpineCare, San Francisco Spine Institute – San Francisco, California, 2006</li>
</ul>
我想在我的主题函数中创建一个短代码API。php我已经使用了以下代码,但它并没有像我需要的那样工作。
function coregnie_list_ul( $atts, $content = null ) {
//var_dump($atts);
return \'<ul \'.$atts->style .\' >\'.do_shortcode($content).\'</ul>\';
}
add_shortcode(\'ul\', \'coregnie_list_ul\');
function coregnie_list_li( $atts, $content = null ) {
return \'<li>\'.do_shortcode($content).\'</li>\';
}
add_shortcode(\'li\', \'coregnie_list_li\');