I Learning WordPress and I do my first plugin, this is the code:
...
<?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 read the pluging properly but when I activate it doesn’t appear on my WordPress Dashboard Menu, and I don’t know why. Once the plugin is activated, it will show up in WordPress menus, and it should reflect the interactive interface to the user, but it doesn’t. With the icon that I put on it, the drop-down menu that I put on it and the class creation interface.
I saw a similar plugin on a Udemy course, I mirror that code and work perfectly but my code doesn’t, can somebody please help me.
2
Answers
Must not exceed 20 characters in register_post_type function
Please try
https://developer.wordpress.org/reference/functions/register_post_type/
$post_type
(string) (Required) Post type key. Must not exceed 20 characters and may only contain lowercase alphanumeric characters, dashes, and underscores.
Shorten and remove the Camel Case.
register_post_type( 'sportscollege_class', $args );