我需要一个简短问题的帮助。
我有以下代码:
add_shortcode("archive", "archive_render");
function archive_render($atts) {
extract(shortcode_atts(array(
"rientro" => "no",
"year" => "",
), $atts));
global $wpdb;
$rientro == "si" ? $rientro = "yes" : "no";
$query = "SELECT event_name FROM wp_em_events WHERE EXTRACT(YEAR FROM event_end_date) = ".$year." AND event_end_date < CURDATE()";
$pasts_event = $wpdb->get_col($query);
function get_pasts_event( $pasts_event ){
foreach ( $pasts_event as $past_event_slug ) {
$output .= "<li><a href=\'".get_site_url()."/eventi/".$past_event_slug."\'>$past_event_slug</a></li>";
}
return $output;
}
$string = \'[one_third last="\'.$rientro.\'" class="" id=""][accordian class="" id=""][toggle title="\'.$year.\'" open="no"]<ul>\'.get_pasts_event($pasts_event).\'</ul>[/toggle][/accordian][/one_third]\';
echo do_shortcode( $string );
}
如果在WP编辑器中添加两次或更多,则只会执行第一次,页面停止工作。
有人知道为什么我的短代码不能被多次使用吗?