Search code examples
wordpresscustom-post-type

How to create custom post types in WordPress?


I want to know the procedure of how to create custom post types with WordPress. I will be thankful if anyone help me with complete procedure of code and plugins. I will also be writing a blog post regarding this issue and I need help from top contributors of Stackoverflow.


Solution

  • Add code similar to this to your functions.php

    add_action( 'init', 'create_post_type' );
    function create_post_type() {
        register_post_type( 'your_custom_name',
            array(
                'labels' => array(
                    'name' => __( 'Custom_names' ),
                    'singular_name' => __( 'Custom_names' )
                ),
            'public' => true,
            'has_archive' => true,
            )
        );
    }
    

    after it you can see a another option in your dashbooard left bar to add custom post. see more about Post Types