即使这个问题是离题的,您也可以使用WordPress专用函数来检索所有事件自定义字段,并在模板中显示它们,或者在脚本中使用它们。
你可以看看WP_Query 检索事件的post类型和get_post_meta() 对于任何自定义字段。当然,您也可以使用插件创建的专用函数,但这是离题的。
$args = array(\'post_type\'=>\'event\', \'post_status\'=>\'publish\', \'posts_per_page\'=>-1);
$event_query = new WP_Query($args);
if ( $the_query->have_posts() ) {
echo \'<ul>\';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo get_post_meta($post->ID, \'event_start_date\', true);
echo get_post_meta($post->ID, \'event_end_date\', true);
echo \'<li>\' . get_the_title() . \'</li>\';
}
echo \'</ul>\';
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
希望有帮助!