0
X
Add Snippet To Project
New Project
Add To Existing Project
/**
* Registers a custom post type 'news'.
*
* @since 1.0.0
*
* @return void
*/
function wh_custompost_news() : void {
$labels = [
'name' => _x( 'Newss', 'Post Type General Name', 'wh' ),
'singular_name' => _x( 'News', 'Post Type Singular Name', 'wh' ),
'menu_name' => __( 'Newss', 'wh' ),
'name_admin_bar' => __( 'Newss', 'wh' ),
'archives' => __( 'Newss Archives', 'wh' ),
'attributes' => __( 'Newss Attributes', 'wh' ),
'parent_item_colon' => __( 'Parent News:', 'wh' ),
'all_items' => __( 'All Newss', 'wh' ),
'add_new_item' => __( 'Add New News', 'wh' ),
'add_new' => __( 'Add New', 'wh' ),
'new_item' => __( 'New News', 'wh' ),
'edit_item' => __( 'Edit News', 'wh' ),
'update_item' => __( 'Update News', 'wh' ),
'view_item' => __( 'View News', 'wh' ),
'view_items' => __( 'View Newss', 'wh' ),
'search_items' => __( 'Search Newss', 'wh' ),
'not_found' => __( 'News Not Found', 'wh' ),
'not_found_in_trash' => __( 'News Not Found in Trash', 'wh' ),
'featured_image' => __( 'Featured Image', 'wh' ),
'set_featured_image' => __( 'Set Featured Image', 'wh' ),
'remove_featured_image' => __( 'Remove Featured Image', 'wh' ),
'use_featured_image' => __( 'Use as Featured Image', 'wh' ),
'insert_into_item' => __( 'Insert into News', 'wh' ),
'uploaded_to_this_item' => __( 'Uploaded to this News', 'wh' ),
'items_list' => __( 'Newss List', 'wh' ),
'items_list_navigation' => __( 'Newss List Navigation', 'wh' ),
'filter_items_list' => __( 'Filter Newss List', 'wh' ),
];
$labels = apply_filters( 'news-labels', $labels );
$args = [
'label' => __( 'News', 'wh' ),
'description' => __( 'Westhaven news articles', 'wh' ),
'labels' => $labels,
'supports' => [
'title',
'editor',
'excerpt',
'author',
'thumbnail',
],
'taxonomies' => [
'news-type',
],
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-post',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'exclude_from_search' => false,
'has_archive' => true,
'can_export' => true,
'capability_type' => 'page',
'show_in_rest' => true,
];
$args = apply_filters( 'news-args', $args );
register_post_type( 'news', $args );
}
add_action( 'init', 'wh_custompost_news', 0 );