Custom Post Type not showing in admin
-
Hi, I’m trying to create a plugin for “Track” custom post type. Here’s my code:
<?php /** * Plugin Name: My Plugin Name * Plugin URI: https://mydomain.com * Description: Handle the basics with this plugin. * Version: 1.0.0 * Author: Ajayi Olamide * Author URI: https://author.example.com/ */ function track_post_type() { // Set UI labels for Custom Post Type $labels = array( 'name' => _x( 'Tracks', 'Post Type General Name', 'irecore' ), 'singular_name' => _x( 'Track', 'Post Type Singular Name', 'irecore' ), 'menu_name' => __( 'Tracks', 'irecore' ), 'parent_item_colon' => __( 'Parent Tracks', 'irecore' ), 'all_items' => __( 'All Tracks', 'irecore' ), 'view_item' => __( 'View Track', 'irecore' ), 'add_new_item' => __( 'Add New Track', 'irecore' ), 'add_new' => __( 'Add New', 'irecore' ), 'edit_item' => __( 'Edit Track', 'irecore' ), 'update_item' => __( 'Update Track', 'irecore' ), 'search_items' => __( 'Search Track', 'irecore' ), 'not_found' => __( 'Not Track Found', 'irecore' ), 'not_found_in_trash' => __( 'Not found in Trash', 'irecore' ), ); // Set other options for Custom Post Type $args = array( 'label' => __( 'single-tracks', 'irecore' ), 'description' => __( 'Track news and reviews', 'irecore' ), 'labels' => $labels, // Features this CPT supports in Post Editor 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ), // You can associate this CPT with a taxonomy or custom taxonomy. 'taxonomies' => array( 'genres' ), /* A hierarchical CPT is like Pages and can have * Parent and child items. A non-hierarchical CPT * is like Posts. */ 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'slug' => 'tracks', 'capability_type' => 'tracks', 'menu_icon' => 'dashicons-music', ); // Registering your Custom Post Type register_post_type( 'tracks', $args ); } /* Hook into the 'init' action so that the function * Containing our post type registration is not * unnecessarily executed. */ add_action( 'init', 'track_post_type', 0 );The problem however is this plugin is activated but I can’t find the Custom Post Type on admin menu. Please is something wrong with the code? Thanks for your help.
The blog I need help with is: (visible only to logged in users)
-
Hi there!
You won’t be able to add this code on WordPress.com:
You may want to create a self-hosted site to try things like that.
To clear up any further confusion, WordPress.com and WordPress.org are two different entities.We, WordPress.com are a cloud-based platform where we manage WordPress sites, whereas WordPress.org is a stand-alone software that you can download and self-host with any other hosting.
You can find more details about WordPress.com and WordPress.org on this support page:
For help and suggestions with your code, I’d recommend posting to the community forums here: https://wordpress.org/support/forums/
- The topic ‘Custom Post Type not showing in admin’ is closed to new replies.