我创建了一个名为(event)的自定义post\\u类型,下面是代码
// Register Custom Post Type Events
function custom_post_type_events() {
$labels = array(
\'name\' => _x( \'Events\', \'Post Type General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Event\', \'Post Type Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Events\', \'text_domain\' ),
\'parent_item_colon\' => __( \'\', \'text_domain\' ),
\'all_items\' => __( \'All Events\', \'text_domain\' ),
\'view_item\' => __( \'View Event\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Event\', \'text_domain\' ),
\'add_new\' => __( \'New Event\', \'text_domain\' ),
\'edit_item\' => __( \'Edit Event\', \'text_domain\' ),
\'update_item\' => __( \'Update Event\', \'text_domain\' ),
\'search_items\' => __( \'Search events\', \'text_domain\' ),
\'not_found\' => __( \'No events found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'No events found in Trash\', \'text_domain\' ),
);
$args = array(
\'label\' => __( \'event\', \'text_domain\' ),
\'description\' => __( \'Events information pages\', \'text_domain\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'author\', \'thumbnail\', \'trackbacks\', \'revisions\', \'custom-fields\', \'post-formats\', ),
\'taxonomies\' => array( \'category\', \'post_tag\' ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'menu_icon\' => admin_url() . \'/images/ef-events-icon.png\', // Icon Path
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => true,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
);
register_post_type( \'event\', $args );
}
// Hook into the \'init\' action
add_action( \'init\', \'custom_post_type_events\', 0 );
然后,我为这个事件post\\u类型创建了一个自定义日期meta\\u框,下面是代码
add_filter( \'cmb_meta_boxes\', \'dt_person_meta_boxes\' );
function dt_person_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array(
\'id\' => \'dt_metabox\',
\'title\' => \'Event Date and Time\',
\'pages\' => array(\'event\'),
\'context\' => \'side\',
\'priority\' => \'high\',
\'show_names\' => true, // Show field names on the left
\'fields\' => array(
array(
\'name\' => \'Event Start Date\',
\'desc\' => \'Pick the date of this event\',
\'id\' => $prefix . \'event_starttextdate\',
\'type\' => \'text_date\'
),
array(
\'name\' => \'Event End Date\',
\'desc\' => \'Pick the date of this event\',
\'id\' => $prefix . \'event_endtextdate\',
\'type\' => \'text_date\'
),
array(
\'name\' => \'Event Time\',
\'desc\' => \'Enter event time (eg. 05:00 p.m.)\',
\'id\' => $prefix . \'event_time\',
\'type\' => \'text\',
\'save\' => true
)
)
);
return $meta_boxes;
}
我的问题是:
如何为自定义post\\u类型(event)构建自定义归档页面,该页面将按自定义元框(event\\u starttextdate)对事件进行排序???
示例:
2013
<事件1
2012
<事件3
2011
<非常感谢您的帮助。