adad

Home » Snippets » adad
0

Created with:

Visibility: 

public

Creator: carlos

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project
					/**
 * Registers a custom post type 'my_post_type'.
 *
 * @since 1.0.0
 *
 * @return void
 */
function wpturbo_register_my_custom_post_type() : void {
	$labels = [
		'name' => _x( 'My Post Types', 'Post Type General Name', 'wpturbo' ),
		'singular_name' => _x( 'My Post Type', 'Post Type Singular Name', 'wpturbo' ),
		'menu_name' => __( 'Items', 'wpturbo' ),
		'name_admin_bar' => __( 'Items', 'wpturbo' ),
		'archives' => __( 'Items Archives', 'wpturbo' ),
		'attributes' => __( 'Items Attributes', 'wpturbo' ),
		'parent_item_colon' => __( 'Parent Item:', 'wpturbo' ),
		'all_items' => __( 'All Items', 'wpturbo' ),
		'add_new_item' => __( 'Add New Item', 'wpturbo' ),
		'add_new' => __( 'Add New', 'wpturbo' ),
		'new_item' => __( 'New Item', 'wpturbo' ),
		'edit_item' => __( 'Edit Item', 'wpturbo' ),
		'update_item' => __( 'Update Item', 'wpturbo' ),
		'view_item' => __( 'View Item', 'wpturbo' ),
		'view_items' => __( 'View Items', 'wpturbo' ),
		'search_items' => __( 'Search Items', 'wpturbo' ),
		'not_found' => __( 'Item Not Found', 'wpturbo' ),
		'not_found_in_trash' => __( 'Item Not Found in Trash', 'wpturbo' ),
		'featured_image' => __( 'Featured Image', 'wpturbo' ),
		'set_featured_image' => __( 'Set Featured Image', 'wpturbo' ),
		'remove_featured_image' => __( 'Remove Featured Image', 'wpturbo' ),
		'use_featured_image' => __( 'Use as Featured Image', 'wpturbo' ),
		'insert_into_item' => __( 'Insert into Item', 'wpturbo' ),
		'uploaded_to_this_item' => __( 'Uploaded to this Item', 'wpturbo' ),
		'items_list' => __( 'Items list', 'wpturbo' ),
		'items_list_navigation' => __( 'Items list navigation', 'wpturbo' ),
		'filter_items_list' => __( 'Filter items list', 'wpturbo' ),
	];
	$labels = apply_filters( 'my_post_type-labels', $labels );

	$args = [
		'label' => __( 'My Post Type', 'wpturbo' ),
		'description' => __( 'My Post Type Description', 'wpturbo' ),
		'labels' => $labels,
		'supports' => [
			'title',
			'editor',
		],
		'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' => false,
		'can_export' => false,
		'capability_type' => 'page',
		'show_in_rest' => true,
	];
	$args = apply_filters( 'my_post_type-args', $args );

	register_post_type( 'my_post_type', $args );
}
add_action( 'init', 'wpturbo_register_my_custom_post_type', 0 );
				

d

Register an account to save your snippets or go Pro to get more features.