我正在使用新的自定义帖子类型为 wordpress 网站开发一个插件。但是,当我使用 wordpress 的内置函数来获取帖子类型名称 (get_post_type()) 时,它会返回“post”而不是“destinations”。有人可以帮我吗?
这里是注册帖子类型的代码:
// Register Custom Post Type
function paradises_destinations_install()
{
$labels = array(
'name' => _x( 'Destinations', 'Destinations', 'paradises' ),
'singular_name' => _x( 'Destination', 'Destination', 'paradises' ),
'menu_name' => __( 'Destination', 'paradises' ),
'parent_item_colon' => __( 'Parent Destionation', 'paradises' ),
'all_items' => __( 'All Destinations', 'paradises' ),
'view_item' => __( 'View Destination', 'paradises' ),
'add_new_item' => __( 'Add New Destination', 'paradises' ),
'add_new' => __( 'New Destination', 'paradises' ),
'edit_item' => __( 'Edit Destination', 'paradises' ),
'update_item' => __( 'Update Destination', 'paradises' ),
'search_items' => __( 'Search destinations', 'paradises' ),
'not_found' => __( 'No destinations found', 'paradises' ),
'not_found_in_trash' => __( 'No destinations found in Trash', 'paradises' ),
);
$args = array(
'label' => __( 'destinations', 'paradises' ),
'description' => __( 'Destination', 'paradises' ),
'labels' => $labels,
'supports' => array('title','editor','thumbnail'),
'taxonomies' => array('region'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 100,
'menu_icon' => '',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
);
register_post_type('destinations', $args );
}
// Hook into the 'init' action
add_action( 'init', 'paradises_destinations_install', 0 );