Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

WordPress custom post type not appearing in wp-admin left nav-bar

I am new to WordPress and hence learning to make custom plugins. For this purpose, I have taken a fresh Bluehost account to practice things on it. As this account is fresh, no other plugin is installed over it.

Following this tutorial, I make a custom plugin. That plugin appeared in the plugins tab. But when I activate it, the Custom post type does not appear in WP-admin left nav-bar. I then followed another tutorial, but the same thing happened. My DEBUG is on, but no error gets thrown. I have tried all solutions given on google but no result.

Plugin file:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function tutsplus_register_post_type() {
 
    // movies
 
    $labels = array(  
        'name' => __( 'Movies' , 'tutsplus' ), 
        'singular_name' => __( 'Movie' , 'tutsplus' ), 
        'add_new' => __( 'New Movie' , 'tutsplus' ), 
        'add_new_item' => __( 'Add New Movie' , 'tutsplus' ), 
        'edit_item' => __( 'Edit Movie' , 'tutsplus' ), 
        'new_item' => __( 'New Movie' , 'tutsplus' ), 
        'view_item' => __( 'View Movie' , 'tutsplus' ), 
        'search_items' => __( 'Search Movies' , 'tutsplus' ), 
        'not_found' =>  __( 'No Movies Found' , 'tutsplus' ), 
        'not_found_in_trash' => __( 'No Movies found in Trash' , 'tutsplus' ), 
    );
 
    $args = array(
 
        'labels' => $labels, 
        'has_archive' => true, 
        'public' => true, 
        'hierarchical' => false, 
        'supports' => array( 
            'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail', 'page-attributes' 
        ), 
        'rewrite'   => array( 'slug' => 'movies' ), 
        'show_in_rest' => true 
    ); 
}

add_action( 'init', 'tutsplus_register_post_type' );

Can anyone help me in this regard?

>Solution :

You forget to register_post_type. try the below code.

function tutsplus_register_post_type() {
 
    // movies 
    $labels = array(  
        'name' => __( 'Movies' , 'tutsplus' ), 
        'singular_name' => __( 'Movie' , 'tutsplus' ), 
        'add_new' => __( 'New Movie' , 'tutsplus' ), 
        'add_new_item' => __( 'Add New Movie' , 'tutsplus' ), 
        'edit_item' => __( 'Edit Movie' , 'tutsplus' ), 
        'new_item' => __( 'New Movie' , 'tutsplus' ), 
        'view_item' => __( 'View Movie' , 'tutsplus' ), 
        'search_items' => __( 'Search Movies' , 'tutsplus' ), 
        'not_found' =>  __( 'No Movies Found' , 'tutsplus' ), 
        'not_found_in_trash' => __( 'No Movies found in Trash' , 'tutsplus' ), 
    );
 
    $args = array(
 
        'labels' => $labels, 
        'has_archive' => true, 
        'public' => true, 
        'hierarchical' => false, 
        'supports' => array( 
            'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail', 'page-attributes' 
        ), 
        'rewrite'   => array( 'slug' => 'movies' ), 
        'show_in_rest' => true 
    ); 

    register_post_type( 'movies', $args );
    
}
add_action( 'init', 'tutsplus_register_post_type' );

Tested and works

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading