有很多方法可以做到这一点,但我将首先为Members, 您可以通过在主题函数中粘贴此代码来创建它。php使用以下代码:
function member_name() {
$labels = array(
\'name\' => _x( \'Member Name\', \'Post Type General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Member Name\', \'Post Type Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Members\', \'text_domain\' ),
\'name_admin_bar\' => __( \'Member Name\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Member\', \'text_domain\' ),
\'all_items\' => __( \'All Members\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Member \', \'text_domain\' ),
\'add_new\' => __( \'Add New\', \'text_domain\' ),
\'new_item\' => __( \'New Member \', \'text_domain\' ),
\'edit_item\' => __( \'Edit Member \', \'text_domain\' ),
\'update_item\' => __( \'Update Member \', \'text_domain\' ),
\'view_item\' => __( \'View Member \', \'text_domain\' ),
\'search_items\' => __( \'Search Member \', \'text_domain\' ),
\'not_found\' => __( \'Not found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'text_domain\' ),
\'items_list\' => __( \'Member list\', \'text_domain\' ),
\'items_list_navigation\' => __( \'Member list navigation\', \'text_domain\' ),
\'filter_items_list\' => __( \'Filter Member list\', \'text_domain\' ),
);
$args = array(
\'label\' => __( \'Member Name\', \'text_domain\' ),
\'description\' => __( \'Member Description\', \'text_domain\' ),
\'labels\' => $labels,
\'supports\' => array( ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'show_in_admin_bar\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
);
register_post_type( \'member_name\', $args );
}
add_action( \'init\', \'member_name\', 0 );
请参阅此处,以获取帖子类型的完整文档:codex。wordpress。组织/职位类型
拥有自定义帖子类型后,添加与自定义帖子类型相关的字段(生日、职位等)的最简单方法是使用ACF插件www.advancedcustomfields。com/or您可以通过了解meta-box与自定义post类型一起工作来对其进行编码,请参阅此处:codex。wordpress。组织/职能\\参考/添加\\元\\框
最后,在设置成员列表、将其与适当的字段关联并填充数据后,可以在主题中显示它,例如在默认主页中,让我们使用索引。php例如,在主题文件夹中,您可以插入以下示例代码,以使用wp\\U查询来显示和排序与自定义帖子类型关联的自定义元:
$args = array (
\'post_type\' => array( \'member_name\' ),
\'order\' => \'ASC\',
\'orderby\' => \'date\',
\'meta_query\' => array(
array(
\'key\' => \'birthdate\',
\'type\' => \'DATE\',
),
),
);
// The Query
$query = new WP_Query( $args );
请参阅Wp\\U query的文档以了解更深入的用法:codex。wordpress。组织/Class\\u引用/WP\\u查询