用户2587741在问题中发布了他们问题的答案:
$tabs_divs = \'\';
function tabs_group($atts, $content = null ) {
global $tabs_divs;
$tabs_divs = \'\';
$output = \'<div id="tab-side-container"><ul\';
$output.=\'>\'.do_shortcode($content).\'</ul>\';
$output.= \'<div class="panel-container">\'.$tabs_divs.\'</div>\';
return $output;
}
function tab($atts, $content = null) {
global $tabs_divs;
extract(shortcode_atts(array(
\'id\' => \'\',
\'title\' => \'\',
), $atts));
if(empty($id))
$id = \'side-tab\'.rand(100,999);
$output = \'
<li>
<a href="#\'.$id.\'">\'.$title.\'</a>
</li>
\';
$tabs_divs.= \'<div id="\'.$id.\'">\'.$content.\'</div>\';
return $output;
}
add_shortcode(\'tabs\', \'tabs_group\');
add_shortcode(\'tab\', \'tab\');