WordPress custom post type with custom capabilities – permalink link on edit page goes back to edit screen

Running into a very odd thing with WordPress custom post types with custom capabilities assigned:

When custom capabilities are assigned, the Permalink “link” (the one that shows up underneath the title field of the WordPress edit screen) stops linking to the actual post, and starts linking to the edit screen.

If I remove the custom capabilities, it goes back to working perfectly. I’m sure I’m simply missing obvious, but just not sure what it might be.

CPT code is such:

$labels = array(
    'name'                => _x( 'Plants', 'Post Type General Name', 'nsfs_non_fran' ),
    'singular_name'       => _x( 'Plants', 'Post Type Singular Name', 'nsfs_non_fran' ),
    'menu_name'           => __( 'Plants', 'nsfs_non_fran' ),
    'parent_item_colon'   => __( 'Parent Plants:', 'nsfs_non_fran' ),
    'all_items'           => __( 'All Plants', 'nsfs_non_fran' ),
    'view_item'           => __( 'View Plants', 'nsfs_non_fran' ),
    'add_new_item'        => __( 'Add New Plants', 'nsfs_non_fran' ),
    'add_new'             => __( 'Add New', 'nsfs_non_fran' ),
    'edit_item'           => __( 'Edit Plants', 'nsfs_non_fran' ),
    'update_item'         => __( 'Update Plants', 'nsfs_non_fran' ),
    'search_items'        => __( 'Search Plants', 'nsfs_non_fran' ),
    'not_found'           => __( 'Not found', 'nsfs_non_fran' ),
    'not_found_in_trash'  => __( 'Not found in Trash', 'nsfs_non_fran' ),
);

$capabilities = array(
    'edit_post'             => 'edit_plant',
    'read_post'             => 'read_plant',
    'delete_post'           => 'delete_plant',
    'edit_posts'            => 'edit_plant',
    'edit_others_posts'     => 'edit_others_plant',
    'publish_posts'         => 'publish_plant',
    'read_private_posts'    => 'read_private_plant',
);

$args = array(
    'label'               => __( 'Plants', 'nsfs_non_fran' ),
    'description'         => __( 'Plants', 'nsfs_non_fran' ),
    'labels'              => $labels,
    'supports'            => array( 'title', 'editor', 'thumbnail', 'page-attributes' ),
    'taxonomies'          => array( 'post_tag', 'genus' ),
    'hierarchical'        => true,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 20,
    'menu_icon'           => 'dashicons-format-image',
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => $capabilities,
    'rewrite'             => array( 'slug' => 'genera' ),
);
register_post_type( 'genera', $args );

Read more here: WordPress custom post type with custom capabilities – permalink link on edit page goes back to edit screen

Leave a Reply

Your email address will not be published. Required fields are marked *