Wordpress Custom Post Type Generator Tool

Supports:

Generated Function:

Copy and use below hooks in functions.php


                            function custom_post_type() {
                                $labels = array(
                                    'name'                  => _x( 'Custom Posts', 'Portfolio General Name', 'Textdomain' ),
                                    'singular_name' => _x( 'Custom Post', 'Post Type Singular Name', 'Textdomain' ),
                                    'menu_name' => _x( 'Custom Posts', 'Admin Menu text', 'Textdomain' ),
                                    'name_admin_bar' => _x( 'portfolio', 'Add New on Toolbar', 'Textdomain' ),
                                    'archives' => __( 'portfolio Archives', 'Textdomain' ),
                                    'attributes' => __( 'portfolio Attributes', 'Textdomain' ),
                                    'parent_item_colon' => __( 'Parent portfolio:', 'Textdomain' ),
                                    'all_items' => __( 'All Custom Posts', 'Textdomain' ),
                                    'add_new_item' => __( 'Add New portfolio', 'Textdomain' ),
                                    'add_new' => __( 'Add New', 'Textdomain' ),
                                    'new_item' => __( 'New portfolio', 'Textdomain' ),
                                    'edit_item' => __( 'Edit portfolio', 'Textdomain' ),
                                    'update_item' => __( 'Update portfolio', 'Textdomain' ),
                                    'view_item' => __( 'View portfolio', 'Textdomain' ),
                                    'view_items' => __( 'View Custom Posts', 'Textdomain' ),
                                    'search_items' => __( 'Search portfolio', 'Textdomain' ),
                                    'not_found' => __( 'Not found', 'Textdomain' ),
                                    'not_found_in_trash' => __( 'Not found in Trash', 'Textdomain' ),
                                    'featured_image' => __( 'Featured Image', 'Textdomain' ),
                                    'set_featured_image' => __( 'Set featured image', 'Textdomain' ),
                                    'remove_featured_image' => __( 'Remove featured image', 'Textdomain' ),
                                    'use_featured_image' => __( 'Use as featured image', 'Textdomain' ),
                                    'insert_into_item' => __( 'Insert into portfolio', 'Textdomain' ),
                                    'uploaded_to_this_item' => __( 'Uploaded to this Custom Post', 'Textdomain' ),
                                    'items_list' => __( 'Custom Posts list', 'Textdomain' ),
                                    'items_list_navigation' => __( 'Custom Posts list navigation', 'Textdomain' ),
                                    'filter_items_list' => __( 'Filter Custom Posts list', 'Textdomain' ),
                                );
                                $args = array(
                                    'label'               => __( 'Custom Posts', 'Textdomain' ),
                                    'supports'            => ["title","editor"],
                                    'taxonomies'          => ["post_tag"],
                                    'description'         => __( 'Custom Posts', 'Textdomain' ),
                                    'labels'              => $labels,
                                    'menu_icon'           => 'dashicons-admin-appearance',
                                    'public'              => true,
                                    'show_ui'             => true,
                                    'show_in_menu'        => true,
                                    'menu_position'       => 5,
                                    'show_in_admin_bar'   => true,
                                    'show_in_nav_menus'   => false,
                                    'can_export'          => false,
                                    'has_archive'         => true,
                                    'hierarchical'        => false,
                                    'exclude_from_search' => false,
                                
                                
                                    'show_in_rest'        => true,
                                    'publicly_queryable'  => true,
                                    'capability_type'     => 'post',
                                );
                                register_post_type( 'custompost', $args );
                                }
                                
                                add_action( 'init', 'custom_post_type', 0 );