这是我将使用的代码:
$open_shortcode = \'[vc_accordion]\';
$shortcode_data = \'\';
$close_shortcode = \'[/vc_accordion]\';
$myarray = array(
\'tabs\' =>
array(
\'title\' => \'Section 1\',
\'content\' => \'Any text here\'
),
array(
\'title\' => \'Section 2\',
\'content\' => \'Any text here\'
)
);
foreach( $myarray[\'tabs\'] as $tab ){
$shortcode_data .= \'[vc_accordion_tab title="\' . $tab[\'title\'] . \'"]\' . $tab[\'content\'] . \'[/vc_accordion_tab]\';
}
echo do_shortcode($open_shortcode . $shortcode_data . $close_shortcode);
假设您想要类似的东西:
[vc_accordion]
[vc_accordion_tab title="Section 1"]Any text here[/vc_accordion_tab]
[vc_accordion_tab title="Section 2"]Any text here[/vc_accordion_tab]
[/vc_accordion]
你提供了很少的细节,这对我们帮助不了你,但我相信这应该会起到作用。