我正在使用WordPress建立网站,使用它的方式更像是CMS,然后是博客平台。我充分利用了自定义帖子类型和自定义分类法。最后但并非最不重要的一点是,我使用WPML插件将其设为多语言。
在CPT声明期间,我包装了字符串和子段,gettext以便在WPML中准备翻译。
CPT声明的示例如下:
register_post_type('rooms',
array(
'label' => __('Rooms','valletta'),
'description' => __('','valletta'),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'hierarchical' => true,
'rewrite' => array('slug' => __('rooms','valletta')),
'query_var' => true,
'exclude_from_search' => false,
'menu_position' => 25,
'supports' => array('title','editor','excerpt','custom-fields','comments',),
'taxonomies' => array('features','typology',),
'labels' => array (
'name' => __('Rooms','valletta'),
'singular_name' => __('room','valletta'),
'menu_name' => __('Rooms','valletta'),
'add_new' => __('Add room','valletta'),
'add_new_item' => __('Add New room','valletta'),
'edit' => __('Edit','valletta'),
'edit_item' => __('Edit room','valletta'),
'new_item' => __('New …Run Code Online (Sandbox Code Playgroud) wordpress translation url-rewriting http-status-code-404 custom-post-type