在管理面板中自定义我的自定义分类表

时间:2013-02-28 作者:micadelli

我已经为我的自定义帖子类型注册了一个新的分类法,现在我正在尝试编辑分类法表。

我已成功删除“说明”列,但我无法找到它how to edit column width for the column that shows the number of custom post types found 在特定的分类法中。该列的CSS类似乎是column-posts, 因此,其宽度设置为10%.

Shouldn\'t the column\'s CSS class be column-{my-custom-post-type} and not the default?

Can I somehow force the column\'s width be set to auto or set its class to match my custom-post-type?

以下是我迄今为止所做的:

Custom Post Type

function registerPersonnelPostType() {
    $labels = array(
        \'name\'                  => __( \'Personnel\', \'xxx\' ),
        \'singular_name\'         => __( \'Personnel\', \'xxx\' ),
        \'add_new\'               => __( \'Add New\', \'xxx\' ),
        \'add_new_item\'          => __( \'Add New Personnel Member\', \'xxx\' ),
        \'edit_item\'             => __( \'Edit Personnel Member\', \'xxx\' ),
        \'new_item\'              => __( \'New Personnel Member\', \'xxx\' ),
        \'view_item\'             => __( \'View Personnel Member\', \'xxx\' ),
        \'search_items\'          => __( \'Search Personnel\', \'xxx\' ),
        \'not_found\'             => __( \'No personnel found\', \'xxx\' ),
        \'not_found_in_trash\'    => __( \'No personnel found in Trash\', \'xxx\' ),
        \'parent_item_colon\'     => __( \'Parent Personnel:\', \'xxx\' ),
        \'menu_name\'             => __( \'Personnel\', \'xxx\' )
    );

    $args = array(
        \'labels\'                => $labels,
        \'hierarchical\'          => true,
        \'description\'           => \'Staff names and descriptions\',
        \'supports\'              => array( \'title\', \'editor\', \'thumbnail\' ),
        \'public\'                => true,
        \'show_ui\'               => true,
        \'show_in_menu\'          => true,
        \'menu_position\'         => 20,
        \'show_in_nav_menus\'     => true,
        \'publicly_queryable\'    => true,
        \'exclude_from_search\'   => false,
        \'has_archive\'           => true,
        \'query_var\'             => true,
        \'can_export\'            => true,
        \'rewrite\'               => true,
        \'capability_type\'       => \'post\'
    );

    register_post_type( \'personnel\', $args );
}
Taxonomy

function departmentInit() {
    $labels = array(        
        \'name\'                  => __( \'Department\', \'xxx\' ),
        \'singular_name\'         => __( \'Department\', \'xxx\' ),
        \'search_items\'          => __( \'Search Departments\', \'xxx\' ),
        \'all_items\'             => __( \'All Departments\', \'xxx\' ),
        \'parent_item\'           => __( \'Parent Department\', \'xxx\' ),
        \'parent_item_colon\'     => __( \'Parent Department:\', \'xxx\' ),
        \'edit_item\'             => __( \'Edit Department\', \'xxx\' ),
        \'update_item\'           => __( \'Update Department\', \'xxx\' ),
        \'add_new_item\'          => __( \'Add New Department\', \'xxx\' ),
        \'new_item_name\'         => __( \'New Department Name\', \'xxx\' ),
        \'menu_name\'             => __( \'Department\', \'xxx\' )
    );

    $args = array(
        \'labels\'                => $labels,
        \'hierarchical\'          => true,
        \'show_ui\'               => true,
        \'query_var\'             => true,
        \'rewrite\'               => array( \'slug\' => \'department\' )
    );

    register_taxonomy( \'department\' , array(\'personnel\'), $args );
}
Hooks for editing columns

add_filter( \'manage_edit-department_columns\', \'departmentColumns\' );

function departmentColumns( $columns ) {    
    if ( isset( $columns[ \'description\' ] ) ) {
        unset( $columns[ \'description\' ] );
    }

    return $columns;        
}

1 个回复
SO网友:Vinod Dalvi

在函数中添加以下代码。php文件来实现这一点:

add_action(\'admin_head\', \'my_custom_fonts\');

function my_custom_fonts() {
  echo \'<style>
   #posts.column-posts{width:auto;}
} 
</style>\';
}

结束

相关推荐

仅在论坛目录上加载bbPress css文件

我在我的网站上添加了bbpress论坛插件来处理讨论、论坛或评论。bbPress CSS文件被添加到我博客的每个页面。现在,考虑到页面速度,我只想将其加载到论坛目录。有没有办法做到这一点?