用户自定义帖子类型的WordPress仅创建一项

时间:2018-08-29 23:26:52

标签: php wordpress

我创建了一个基本的帖子类型项目,名称为“公共调整者”,新用户“订阅者”将只能在此帖子类型中创建一个项目(公共调整者),因此它将仅出现在菜单中我的项目”,它可以直接编辑该项目。我正在使用POST类型的ui插件wordpress。

/**
     * Post Type: Public Adjusters.
     */

    $labels = array(
        "name" => __( "Public Adjusters", "" ),
        "singular_name" => __( "Public Adjuster", "" ),
        "menu_name" => __( "Public Adjusters", "" ),
        "all_items" => __( "All Public Adjusters", "" ),
        "add_new" => __( "Add New", "" ),
        "add_new_item" => __( "Add New Public Adjuster", "" ),
        "edit_item" => __( "Edit Public Adjuster", "" ),
        "new_item" => __( "New Public Adjuster", "" ),
        "view_item" => __( "View Public Adjuster", "" ),
        "view_items" => __( "View Public Adjusters", "" ),
        "search_items" => __( "Search Public Adjusters", "" ),
        "not_found" => __( "No Public Adjusters Found", "" ),
        "not_found_in_trash" => __( "No Public Adjusters found in trash", "" ),
        "parent_item_colon" => __( "Parent Public Adjuster", "" ),
        "featured_image" => __( "Featured Image", "" ),
        "set_featured_image" => __( "Set Featured Image", "" ),
        "remove_featured_image" => __( "Remove Featured Image", "" ),
        "use_featured_image" => __( "Use Featured Image", "" ),
        "archives" => __( "Archives", "" ),
        "insert_into_item" => __( "Insert into Public Adjuster", "" ),
        "uploaded_to_this_item" => __( "Uploaded to this Item Public Adjuster", "" ),
        "filter_items_list" => __( "Filter Public Adjusters List", "" ),
        "items_list_navigation" => __( "Public Adjuster List Navigation", "" ),
        "items_list" => __( "Public Adjusters List", "" ),
        "attributes" => __( "Public Adjuster Attribute", "" ),
        "parent_item_colon" => __( "Parent Public Adjuster", "" ),
    );

    $args = array(
        "label" => __( "Public Adjusters", "" ),
        "labels" => $labels,
        "description" => "",
        "public" => true,
        "publicly_queryable" => true,
        "show_ui" => true,
        "show_in_rest" => false,
        "rest_base" => "",
        "has_archive" => false,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "exclude_from_search" => false,
        "capability_type" => "post",
        "map_meta_cap" => true,
        "hierarchical" => false,
        "rewrite" => array( "slug" => "public_adjusters", "with_front" => true ),
        "query_var" => true,
        "supports" => array( "title" ),
        "taxonomies" => array( "category", "locations" ),
    );

    register_post_type( "public_adjusters", $args );

0 个答案:

没有答案