如何在自定义帖子类型中添加额外的元框或文本区

时间:2015-02-17 作者:Dragut

尝试创建自定义主页滑块并在图像上添加“阅读更多”链接,但我无法插入额外的meta 盒子或textareas

function featured_image_slider() {
$labels = array(
\'name\' => _x(\'Sliders\', \'post type general name\'),
\'singular_name\' => _x(\'Slider\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'slider\'),
\'add_new_item\' => __(\'Add New Slider\'),
\'edit_item\' => __(\'Edit Slider\'),
\'new_item\' => __(\'New Slider\'),
\'all_items\' => __(\'All Sliders\'),
\'view_item\' => __(\'View Slider\'),
\'search_items\' => __(\'Search Sliders\'),
\'not_found\' =>  __(\'No sliders found\'),
\'not_found_in_trash\' => __(\'No sliders found in Trash\'), 
\'parent_item_colon\' => \'\',
\'menu_name\' => __(\'Sliders\')

);
$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\', \'thumbnail\', \'custom-fields\', )
); 
register_post_type(\'slider\',$args);
}
add_action( \'init\', \'featured_image_slider\' );
enter image description here

1 个回复
SO网友:Gaius

我建议您查看Post Meta框的侧面。这里有一个很好的指南->http://www.paulund.co.uk/create-custom-meta-boxes

(这更多的是评论,但我的声誉不允许我添加评论)

结束

相关推荐

Multisite and plugins options

我需要更多关于get_site_option(), update_site_option() 和add_site_option().在codex中,他们说它与单次安装相同,只是在多站点中,它返回网络范围的选项。好吧,但我对这一点感到困惑:这是否意味着一旦设置了网络范围选项,所有站点的选项都是相同的?还是每个站点都会覆盖它?我的意思是如果我这样做: update_site_option(\'option_group\', \'default_options());// default_options() r