是的,是自定义帖子类型和自定义字段的组合。由于从技术上讲,每个帖子都是一个外部资源,因此您需要为URL设置一个自定义字段。
“Headline”将是标题,“Publication date”可以是发布日期,或者自定义字段“Publication logo”可以是特色图像,“snippet”将放在内容(编辑器)框中这是创建自定义发布类型的代码:
function register_news_cpt() {
$labels = array(
\'name\' => \'News\',
\'singular_name\' =>\'News\',
\'menu_name\' =>\'News\',
\'name_admin_bar\' =>\'News\',
\'parent_item_colon\' =>\'Parent News Item:\',
\'all_items\' =>\'All News\',
\'add_new_item\' =>\'Add New Item\',
\'add_new\' =>\'Add New\',
\'new_item\' =>\'New Item\',
\'edit_item\' =>\'Edit Item\',
\'update_item\' =>\'Update Item\',
\'view_item\' =>\'View Item\',
\'search_items\' =>\'Search News\',
\'not_found\' =>\'Not found\',
\'not_found_in_trash\' =>\'Not found in Trash\',
);
$args = array(
\'label\' =>\'News\',
\'description\' =>\'News\',
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'custom-fields\', ),
\'taxonomies\' => array( \'category\', \'post_tag\' ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'menu_icon\' => \'dashicons-media-document\',
\'show_in_admin_bar\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
\'has_archive\' => false,
\'exclude_from_search\' => true,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
);
register_post_type( \'news\', $args );
}
add_action( \'init\', \'register_news_cpt\', 0 );