CPT from wpcli scaffold not showing in menu.
-
Hi there,
Based on the codex, I have started playing with
wp scaffold post-type movie --label=Movie --theme=twentytwentyone
I do have the php file created under wp-content/themes/post-types/movie.php
However there’s no movie post type appearing in the left menu.
Permalinks refreshed, menu position changed, following parameters verified :
'public' => true, 'hierarchical' => false, 'show_ui' => true, 'show_in_nav_menus' => true,
Am I missing a step?
Thanks!
here’s the untouched code inside the php file :
<?php /** * Registers the <code>movie</code> post type. */ function movie_init() { register_post_type( 'movie', array( 'labels' => array( 'name' => __( 'Movies', 'twentytwentyone' ), 'singular_name' => __( 'Movie', 'twentytwentyone' ), 'all_items' => __( 'All Movies', 'twentytwentyone' ), 'archives' => __( 'Movie Archives', 'twentytwentyone' ), 'attributes' => __( 'Movie Attributes', 'twentytwentyone' ), 'insert_into_item' => __( 'Insert into Movie', 'twentytwentyone' ), 'uploaded_to_this_item' => __( 'Uploaded to this Movie', 'twentytwentyone' ), 'featured_image' => _x( 'Featured Image', 'movie', 'twentytwentyone' ), 'set_featured_image' => _x( 'Set featured image', 'movie', 'twentytwentyone' ), 'remove_featured_image' => _x( 'Remove featured image', 'movie', 'twentytwentyone' ), 'use_featured_image' => _x( 'Use as featured image', 'movie', 'twentytwentyone' ), 'filter_items_list' => __( 'Filter Movies list', 'twentytwentyone' ), 'items_list_navigation' => __( 'Movies list navigation', 'twentytwentyone' ), 'items_list' => __( 'Movies list', 'twentytwentyone' ), 'new_item' => __( 'New Movie', 'twentytwentyone' ), 'add_new' => __( 'Add New', 'twentytwentyone' ), 'add_new_item' => __( 'Add New Movie', 'twentytwentyone' ), 'edit_item' => __( 'Edit Movie', 'twentytwentyone' ), 'view_item' => __( 'View Movie', 'twentytwentyone' ), 'view_items' => __( 'View Movies', 'twentytwentyone' ), 'search_items' => __( 'Search Movies', 'twentytwentyone' ), 'not_found' => __( 'No Movies found', 'twentytwentyone' ), 'not_found_in_trash' => __( 'No Movies found in trash', 'twentytwentyone' ), 'parent_item_colon' => __( 'Parent Movie:', 'twentytwentyone' ), 'menu_name' => __( 'Movies', 'twentytwentyone' ), ), 'public' => true, 'hierarchical' => false, 'show_ui' => true, 'show_in_nav_menus' => true, 'supports' => array( 'title', 'editor' ), 'has_archive' => true, 'rewrite' => true, 'query_var' => true, 'menu_position' => null, 'menu_icon' => 'dashicons-admin-post', 'show_in_rest' => true, 'rest_base' => 'movie', 'rest_controller_class' => 'WP_REST_Posts_Controller', ) ); } add_action( 'init', 'movie_init' ); /** * Sets the post updated messages for the <code>movie</code> post type. * * @param array $messages Post updated messages. * @return array Messages for the <code>movie</code> post type. */ function movie_updated_messages( $messages ) { global $post; $permalink = get_permalink( $post ); $messages['movie'] = array( 0 => '', // Unused. Messages start at index 1. /* translators: %s: post permalink */ 1 => sprintf( __( 'Movie updated. <a target="_blank" href="%s">View Movie</a>', 'twentytwentyone' ), esc_url( $permalink ) ), 2 => __( 'Custom field updated.', 'twentytwentyone' ), 3 => __( 'Custom field deleted.', 'twentytwentyone' ), 4 => __( 'Movie updated.', 'twentytwentyone' ), /* translators: %s: date and time of the revision */ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Movie restored to revision from %s', 'twentytwentyone' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, /* translators: %s: post permalink */ 6 => sprintf( __( 'Movie published. <a href="%s">View Movie</a>', 'twentytwentyone' ), esc_url( $permalink ) ), 7 => __( 'Movie saved.', 'twentytwentyone' ), /* translators: %s: post permalink */ 8 => sprintf( __( 'Movie submitted. <a target="_blank" href="%s">Preview Movie</a>', 'twentytwentyone' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), /* translators: 1: Publish box date format, see https://secure.php.net/date 2: Post permalink */ 9 => sprintf( __( 'Movie scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Movie</a>', 'twentytwentyone' ), date_i18n( __( 'M j, Y @ G:i', 'twentytwentyone' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ), /* translators: %s: post permalink */ 10 => sprintf( __( 'Movie draft updated. <a target="_blank" href="%s">Preview Movie</a>', 'twentytwentyone' ), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ), ); return $messages; } add_filter( 'post_updated_messages', 'movie_updated_messages' );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘CPT from wpcli scaffold not showing in menu.’ is closed to new replies.