Wordpress插件开发-我的插件出了问题,我想知道是什么



我正在学习Wordpress,我做了我的第一个插件,这是代码:

...
<?php
/*
Plugin Name: SportsCollege - Post Type
Plugin URI:
Description: Add Post Type to Sports Colleges Web Site
Version: 1.0.0
Author: Manuel Esteban Morales Zuarez
Author URI: https://github.com/Angstromico
Text Domain: SportsCollege
*/
// Register Custom Post Type
function sportsCollege_classes() {
$labels = array(
'name'                  => _x( 'Classes', 'Post Type General Name', 'SportsCollege' ),
'singular_name'         => _x( 'Class', 'Post Type Singular Name', 'SportsCollege' ),
'menu_name'             => __( 'Class', 'SportsCollege' ),
'name_admin_bar'        => __( 'Class', 'SportsCollege' ),
'archives'              => __( 'File', 'SportsCollege' ),
'attributes'            => __( 'Atributes', 'SportsCollege' ),
'parent_item_colon'     => __( 'Main Class', 'SportsCollege' ),
'all_items'             => __( 'Full Classes', 'SportsCollege' ),
'add_new_item'          => __( 'Add Class', 'SportsCollege' ),
'add_new'               => __( 'Add Class', 'SportsCollege' ),
'new_item'              => __( 'New Class', 'SportsCollege' ),
'edit_item'             => __( 'Edit Class', 'SportsCollege' ),
'update_item'           => __( 'Update Class', 'SportsCollege' ),
'view_item'             => __( 'View Class', 'SportsCollege' ),
'view_items'            => __( 'View Classes', 'SportsCollege' ),
'search_items'          => __( 'Search Class', 'SportsCollege' ),
'not_found'             => __( 'Not Find', 'SportsCollege' ),
'not_found_in_trash'    => __( 'Not Find on Recycle Bin', 'SportsCollege' ),
'featured_image'        => __( 'Featured Image', 'SportsCollege' ),
'set_featured_image'    => __( 'Save Featured Image', 'SportsCollege' ),
'remove_featured_image' => __( 'Delete Featured Image', 'SportsCollege' ),
'use_featured_image'    => __( 'Use as Featured Image', 'SportsCollege' ),
'insert_into_item'      => __( 'Insert on Class', 'SportsCollege' ),
'uploaded_to_this_item' => __( 'Add onClass', 'SportsCollege' ),
'items_list'            => __( 'List of Classes', 'SportsCollege' ),
'items_list_navigation' => __( 'Navegation of Classes', 'SportsCollege' ),
'filter_items_list'     => __( 'Filter Classes', 'SportsCollege' ),
);
$args = array(
'label'                 => __( 'Class', 'SportsCollege' ),
'description'           => __( 'Classes for the Website', 'SportsCollege' ),
'labels'                => $labels,
'supports'              => array( 'title', 'editor', 'thumbnail' ),
'hierarchical'          => true,
'public'                => true,
'show_ui'               => true,
'show_in_menu'          => true,
'menu_position'         => 6,
'menu_icon'             => 'dashicons-welcome-learn-more',
'show_in_admin_bar'     => true,
'show_in_nav_menus'     => true,
'can_export'            => true,
'has_archive'           => true,
'exclude_from_search'   => false,
'publicly_queryable'    => true,
'capability_type'       => 'page',
);
register_post_type( 'sportsCollege_classes', $args );
}
add_action( 'init', 'sportsCollege_classes', 0 );
...

Wordpress正确地读取了插件,但当我激活它时,它不会出现在我的Wordpress仪表板菜单上,我不知道为什么。一旦插件被激活,它将显示在Wordpress菜单中,它应该向用户反映交互式界面,但它没有。我放在上面的图标、下拉菜单和类创建界面。我在一个Udemy课程上看到了一个类似的插件,我镜像了那个代码并完美地工作,但我的代码没有,有人能帮我吗?

https://developer.wordpress.org/reference/functions/register_post_type/

$post_type(string((必需(Post类型键。不得超过20个字符,并且只能包含小写字母数字字符、短划线和下划线。

缩短并取下Camel Case。

register_post_type( 'sportscollege_class', $args );

register_post_type函数中不得超过20个字符

请尝试

register_post_type( 'sportsCollege_class', $args );

相关内容

  • 没有找到相关文章

最新更新