自定义贴子类型使特色图像框全宽

时间:2017-06-07 作者:Amir Sasani

我想Featured Image 选择框全宽<有人能帮我吗?

function portfolio_post_type() {

$labels = array(
    \'name\'                  => _x( \'Portfolio\', \'Post Type General Name\', \'33306\' ),
    \'singular_name\'         => _x( \'Portfolio\', \'Post Type Singular Name\', \'33306\' ),
    \'menu_name\'             => __( \'Post Types\', \'33306\' ),
    \'name_admin_bar\'        => __( \'Post Type\', \'33306\' ),
    \'archives\'              => __( \'Item Archives\', \'33306\' ),
    \'attributes\'            => __( \'Item Attributes\', \'33306\' ),
    \'parent_item_colon\'     => __( \'Parent Item:\', \'33306\' ),
    \'all_items\'             => __( \'All Items\', \'33306\' ),
    \'add_new_item\'          => __( \'Add New Item\', \'33306\' ),
    \'add_new\'               => __( \'Add New\', \'33306\' ),
    \'new_item\'              => __( \'New Item\', \'33306\' ),
    \'edit_item\'             => __( \'Edit Item\', \'33306\' ),
    \'update_item\'           => __( \'Update Item\', \'33306\' ),
    \'view_item\'             => __( \'View Item\', \'33306\' ),
    \'view_items\'            => __( \'View Items\', \'33306\' ),
    \'search_items\'          => __( \'Search Item\', \'33306\' ),
    \'not_found\'             => __( \'Not found\', \'33306\' ),
    \'not_found_in_trash\'    => __( \'Not found in Trash\', \'33306\' ),
    \'featured_image\'        => __( \'Featured Image\', \'33306\' ),
    \'set_featured_image\'    => __( \'Set featured image\', \'33306\' ),
    \'remove_featured_image\' => __( \'Remove featured image\', \'33306\' ),
    \'use_featured_image\'    => __( \'Use as featured image\', \'33306\' ),
    \'insert_into_item\'      => __( \'Insert into item\', \'33306\' ),
    \'uploaded_to_this_item\' => __( \'Uploaded to this item\', \'33306\' ),
    \'items_list\'            => __( \'Items list\', \'33306\' ),
    \'items_list_navigation\' => __( \'Items list navigation\', \'33306\' ),
    \'filter_items_list\'     => __( \'Filter items list\', \'33306\' ),
);
$args = array(
    \'label\'                 => __( \'Portfolio\', \'33306\' ),
    \'description\'           => __( \'Portfolio post type\', \'33306\' ),
    \'labels\'                => $labels,
    \'supports\'              => array(\'thumbnail\'),
    \'hierarchical\'          => false,
    \'public\'                => true,
    \'show_ui\'               => true,
    \'show_in_menu\'          => true,
    \'menu_position\'         => 5,
    \'menu_icon\'             => \'dashicons-format-gallery\',
    \'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\',
    \'show_in_rest\'          => true,

);
register_post_type( \'portfolio_post_type\', $args );

}

add_action( \'init\', \'portfolio_post_type\', 0 );

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

我想你是想搬家Featured Image 左栏的元框。将此代码添加到插件或functions.php 活动主题的文件。

add_action( \'do_meta_boxes\', \'wpse_269370_move_featured_image_meta_box\' );

function wpse_269370_move_featured_image_meta_box() {
    remove_meta_box( \'postimagediv\', \'portfolio_post_type\', \'side\' ); // remove meta box of featured image from current location - \'side\'

    add_meta_box( \'postimagediv\', __(\'Featured Image\'), \'post_thumbnail_meta_box\', \'portfolio_post_type\', \'normal\', \'high\' ); // add meta box of featured image again, at new location - \'normal\'
}   

结束

相关推荐