register_post_type for Pages?

时间:2010-09-23 作者:phwd

一直在阅读这个网站和Wordpress Codex,我发现Wordpress中有一个功能可以启用自定义类型的页面。如何执行相同操作以启用页?

或者至少获得显示帖子的选项,以便将帖子放置在页面下?

1 个回复
最合适的回答,由SO网友:sgelob 整理而成

你的问题不太明白。不管怎样,我试着回应。。。在声明新的自定义帖子类型时,可以使用“hierarchy”=>true。

要将此新菜单放置在管理员的其他位置,请使用适当的“menu\\u 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 ),
        )
    );
}

结束

相关推荐