Cannot input custom post type in wordpress

I have the following code in my function.php:

function custom_post_type(){
    $labels = array(
        'name'=> 'Sports',
        'singular_name'=>'Sport',
        'add_new'=>'Add Item',
        'all_item'=>'All Item',
        'add_new_item'=>'Add Item',
        'edit_item'=>'Edit Item',
        'new_item'=>'New Item',
        'view_item'=>'View Item',
        'search_item'=>'Search Sport',
        'not_found'=>'No item found',
        'not_found_in_trash'=>'No items found in trash',
        'parent_item_colon'=>'Parent Item',
        'menu_name'=>'Sports'
    );

    $args= array(
        'labels'=>$labels,
        'public'=>true,
        'has_archive'=>true,
        'publicly_queryable'=>true,
        'query_var'=>true,
        'rewrite'=>true,
        'capability_type'=>'post',
        'hierarchical'=>false,
        'supports'=>array(
            'title',
            'editor',
            'excerpt',
            'thumbnail',
            'revisions'
        ),
        'taxonomies'=>array('category','post_tag'),
        'menu_position'=>null,
        'exclude_from_search'=>false
    );
    register_post_type('sport',$args);
}
add_action('init','custom_post_type');

Is this code correct?

Read More

I dont know why I cannot add a custom post type to my wordpress. This should work but it didn’t.

Is there any place should i go and change?

Related posts

1 comment

  1. Which wordpress version are you using?
    Because it’s perfectly working in wordpress 4.5.0 & 4.5.1.
    So, Update your wordpress Or active another theme and try for it. may be some issue with your wordpress version or theme.

Comments are closed.