They always say the best way to create a custom post in WordPress is by using a plugin which is 100% correct. Plugins help save you loads of work but why use someone’s code yet you don’t know what goes on behind it? What if the plugin got outdated and can’t work with your current version of WordPress after creating a wide number or custom posts, how are you going to get yourself out of the mess? Thought of all that?

How to register a custom post type on Wordpress

Well i believe the best way to register a custom post if by creating it yourself and not relying on the help of a plugin. I have managed to compile a code below that can do the magic for you. All you have to do is replace “Postone” with the name you prefer to be of your custom post.

//Start Registering Custom Post Type (postone
add_action( 'init', 'register_postonepost', 20 );

function register_postonepost() {
    $labels = array(
        'name' => _x( 'Postone', 'my_custom_post','custom' ),
        'singular_name' => _x( 'Postone', 'my_custom_post', 'custom' ),
        'add_new' => _x( 'Add New', 'my_custom_post', 'custom' ),
        'add_new_item' => _x( 'Add New Postone', 'my_custom_post', 'custom' ),
        'edit_item' => _x( 'Edit PostonePost', 'my_custom_post', 'custom' ),
        'new_item' => _x( 'New PostonePost', 'my_custom_post', 'custom' ),
        'view_item' => _x( 'View PostonePost', 'my_custom_post', 'custom' ),
        'search_items' => _x( 'Search PostonePosts', 'my_custom_post', 'custom' ),
        'not_found' => _x( 'No PostonePosts found', 'my_custom_post', 'custom' ),
        'not_found_in_trash' => _x( 'No PostonePosts found in Trash', 'my_custom_post', 'custom' ),
        'parent_item_colon' => _x( 'Parent PostonePost:', 'my_custom_post', 'custom' ),
        'menu_name' => _x( 'Themes Posts', 'my_custom_post', 'custom' ),

    $args = array(
        'labels' => $labels,
        'hierarchical' => false,
        'description' => 'Custom Postone Posts',
        'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'post-formats', 'custom-fields' ),
        'taxonomies' => array( 'post_tag','category'),
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,
        'menu_icon' => get_stylesheet_directory_uri() . '/images/menu1.png',
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => array('slug' => 'themes/%themes_categories%','with_front' => FALSE),
        'public' => true,
        'has_archive' => 'themes',
        'capability_type' => 'post'
    register_post_type( 'postone', $args );
//End custom post

This code is pasted in the theme’s functions.php and works pretty well. You can alternate with the arrays in-case you want the custom post to be limited to some features. Don’t forget to change the url of the menu item as well.