题
一直在读取此站点和WordPress法典,我看到有一个函数可以在WordPress中启用自定义类型的页面。我该如何做同样的启用页面?
还是至少获取将帖子显示在页面下的帖子的选项?
解决方案
您的问题不太清楚。无论如何,我尝试做出响应...当您声明新的自定义帖子类型时,您可以使用'elierarchical'=> true。
要将此新菜单放在管理员中的其他位置中,则使用Proprety“ Menu_position” => 5,。
示例(添加您的functions.php文件):
add_action( 'init', 'create_my_post_types' );
function create_my_post_types() {
register_post_type( 'mycustompages',
array(
'labels' => array(
'name' => __( 'My custom pages' ),
'singular_name' => __( 'My custom page' )
),
'public' => true,
'hierarchical' => true,
'show_ui' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'comments', 'trackbacks', 'author', 'excerpt', 'custom-fields', 'thumbnail' ),
'rewrite' => array( 'slug' => 'mypage', 'with_front' => false ),
)
);
}