• Resolved ilconterik

    (@ilconterik)


    I’ve created a custom post type with the plugin and I’ve also checked the new post type is selected going into Appearance -> Manus -> Screen Options. Still not showing up… I’m pasting below the output of the ‘Get the code’ link:

    function cptui_register_my_cpts_screenplay() {
    
    	/**
    	 * Post Type: Screenplays.
    	 */
    
    	$labels = [
    		"name" => __( "Screenplays", "boston" ),
    		"singular_name" => __( "Screenplay", "boston" ),
    		"menu_name" => __( "My Screenplays", "boston" ),
    		"all_items" => __( "All Screenplays", "boston" ),
    		"add_new" => __( "Add new", "boston" ),
    		"add_new_item" => __( "Add new Screenplay", "boston" ),
    		"edit_item" => __( "Edit Screenplay", "boston" ),
    		"new_item" => __( "New Screenplay", "boston" ),
    		"view_item" => __( "View Screenplay", "boston" ),
    		"view_items" => __( "View Screenplays", "boston" ),
    		"search_items" => __( "Search Screenplays", "boston" ),
    		"not_found" => __( "No Screenplays found", "boston" ),
    		"not_found_in_trash" => __( "No Screenplays found in trash", "boston" ),
    		"parent" => __( "Parent Screenplay:", "boston" ),
    		"featured_image" => __( "Featured image for this Screenplay", "boston" ),
    		"set_featured_image" => __( "Set featured image for this Screenplay", "boston" ),
    		"remove_featured_image" => __( "Remove featured image for this Screenplay", "boston" ),
    		"use_featured_image" => __( "Use as featured image for this Screenplay", "boston" ),
    		"archives" => __( "Screenplay archives", "boston" ),
    		"insert_into_item" => __( "Insert into Screenplay", "boston" ),
    		"uploaded_to_this_item" => __( "Upload to this Screenplay", "boston" ),
    		"filter_items_list" => __( "Filter Screenplays list", "boston" ),
    		"items_list_navigation" => __( "Screenplays list navigation", "boston" ),
    		"items_list" => __( "Screenplays list", "boston" ),
    		"attributes" => __( "Screenplays attributes", "boston" ),
    		"name_admin_bar" => __( "Screenplay", "boston" ),
    		"item_published" => __( "Screenplay published", "boston" ),
    		"item_published_privately" => __( "Screenplay published privately.", "boston" ),
    		"item_reverted_to_draft" => __( "Screenplay reverted to draft.", "boston" ),
    		"item_scheduled" => __( "Screenplay scheduled", "boston" ),
    		"item_updated" => __( "Screenplay updated.", "boston" ),
    		"parent_item_colon" => __( "Parent Screenplay:", "boston" ),
    	];
    
    	$args = [
    		"label" => __( "Screenplays", "boston" ),
    		"labels" => $labels,
    		"description" => "",
    		"public" => true,
    		"publicly_queryable" => true,
    		"show_ui" => true,
    		"show_in_rest" => true,
    		"rest_base" => "",
    		"rest_controller_class" => "WP_REST_Posts_Controller",
    		"has_archive" => false,
    		"show_in_menu" => true,
    		"show_in_nav_menus" => true,
    		"delete_with_user" => false,
    		"exclude_from_search" => false,
    		"capability_type" => "screenplay",
    		"map_meta_cap" => true,
    		"hierarchical" => false,
    		"rewrite" => [ "slug" => "screenplay", "with_front" => true ],
    		"query_var" => true,
    		"menu_position" => 5,
    		"menu_icon" => "dashicons-media-video",
    		"supports" => [ "title", "editor", "thumbnail", "custom-fields", "author" ],
    	];
    
    	register_post_type( "screenplay", $args );
    }
    
    add_action( 'init', 'cptui_register_my_cpts_screenplay' );
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    The two spots that stand out to me are the menu position and the capability type being switched away from “post” without handling the rest of capability mapping (a spot I know we’re weak on with the base plugin).

    I’d change capability type back to post and check again, and then if that doesn’t work, try some different values for menu position.

    Thread Starter ilconterik

    (@ilconterik)

    Thank you, it worked!

    alexnavin

    (@alexnavin)

    Hi, @tw2113. Please, what if the “capability type” can not be default in my case? What can be done?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @alexnavin If you’re for sure needing to customize the capabilities, then there are a couple options to hook in with for filling in the rest that don’t have GUI components.

    1) Give https://github.com/tw2113/custom-post-type-ui-capabilities/ an attempt to see if it matches enough needs. It’s still not super well tested for real life situations, but in terms of hooking into spots, I believe it should be pretty solid.

    2) Use the hooks we have in place right before we pass on to registration, to add the capabilities array and whatnot.

    https://github.com/WebDevStudios/custom-post-type-ui/blob/1.7.3/custom-post-type-ui.php#L506-L518

    The $args variable should be exactly matched up to what you’d expect to pass in to register_post_type and you can add arguments that have missing UI equivalents with CPTUI.

    alexnavin

    (@alexnavin)

    Amazing, thanks a lot, @tw2113 . I will give it a try.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Post Type not appearing in admin menu’ is closed to new replies.