通过自定义帖子类型添加新帖子只提供给我一个选项,我如何获得更多?

时间:2011-10-22 作者:jkupczak

我刚刚在WordPress网站上添加了一个新的自定义帖子类型。

当我去创建一个新帖子时,我唯一需要编辑的选项是“Slug”。通常,对于一篇普通的帖子,你会有格式、类别、帖子标签、特色图片、Excerpy、发送trackback、自定义字段、讨论和作者。

如何让所有这些选项显示在自定义帖子类型下?

这是我用来创建自定义帖子类型的代码。

function create_post_type() {  
        register_post_type( \'intrigue_faculty\',  
                array(  
                        \'labels\' => array(  
                        \'name\' => __( \'Faculty\' ),  
                        \'singular_name\' => __( \'Faculty\' ),
                        \'add_new_item\' => __( \'Add New Faculty Member\' ),
                        \'new_item\' => __( \'Add Faculty\' ),
                        \'add_new\' => __( \'Add Faculty Member\' ),
                        \'view_item\' => __( \'View Faculty Profile\' ),
                        \'not_found\' => __( \'No faculty members found\' ),
                        \'search_items\' => __( \'Search Faculty Members\' ),
                        \'edit_item\' => __( \'Edit Faculty Member Profile\' ),
                        \'description\' => __( \'A collection of the profiles for Intrigue Dance Intensive faculty members.\' )
                    ),  
            \'public\' => true,  
            \'menu_position\' => 5,  
            \'rewrite\' => array(\'slug\' => \'faculty\')  
            )  
    );  
}  

 add_action( \'init\', \'create_post_type\' );  

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

您是否通过add_post_type_support()?

使用此格式:

<?php add_post_type_support( $post_type, $supports ) ?>
The$supports 参数是一个数组,可以包含以下字符串:

“标题”编辑器(内容)\'post-formats\'添加post格式请注意,可以通过register_post_type() 调用,使用supports 参数数组键。请参阅以下缩写版本the Codex example:

<?php
add_action(\'init\', \'codex_custom_init\');
function codex_custom_init() 
{
  $labels = array();
  $args = array(
    \'labels\' => $labels,
    \'public\' => true,
    \'publicly_queryable\' => true,
    \'show_ui\' => true, 
    \'show_in_menu\' => true, 
    \'query_var\' => true,
    \'rewrite\' => true,
    \'capability_type\' => \'post\',
    \'has_archive\' => true, 
    \'hierarchical\' => false,
    \'menu_position\' => null,
    \'supports\' => array(\'title\',\'editor\',\'author\',\'thumbnail\',\'excerpt\',\'comments\')
  ); 
  register_post_type(\'book\',$args);
}
?>

EDIT

使用您自己的代码:

<?php
function create_post_type() {  
    register_post_type( \'intrigue_faculty\',  
            array(  
                \'labels\' => array(  
                    \'name\' => __( \'Faculty\' ),  
                    \'singular_name\' => __( \'Faculty\' ),
                    \'add_new_item\' => __( \'Add New Faculty Member\' ),
                    \'new_item\' => __( \'Add Faculty\' ),
                    \'add_new\' => __( \'Add Faculty Member\' ),
                    \'view_item\' => __( \'View Faculty Profile\' ),
                    \'not_found\' => __( \'No faculty members found\' ),
                    \'search_items\' => __( \'Search Faculty Members\' ),
                    \'edit_item\' => __( \'Edit Faculty Member Profile\' ),
                    \'description\' => __( \'A collection of the profiles for Intrigue Dance Intensive faculty members.\' )
                ),  
            \'public\' => true,  
            \'menu_position\' => 5,  
            \'rewrite\' => array(\'slug\' => \'faculty\'), // Don\'t forget this comma
            // ADD ME HERE; LIST WHATEVER FEATURES FOR WHICH YOU WANT TO ADD SUPPORT
            \'supports\' => array(\'title\',\'editor\',\'author\',\'thumbnail\',\'excerpt\',\'comments\') 
        )  
    );  
}  
?>
add\\u action(\'init\',\'create\\u post\\u type\');

结束

相关推荐