Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to wp create post type in wordpress


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Our custom post type function
function create_posttype() {
 
    register_post_type( 'movies',
    // CPT Options
        array(
            'labels' => array(
                'name' => __( 'Movies' ),
                'singular_name' => __( 'Movie' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'movies'),
            'show_in_rest' => true,
 
        )
    );
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
Source by developer.wordpress.org #
 
PREVIOUS NEXT
Tagged: #wp #create #post #type #wordpress
ADD COMMENT
Topic
Name
2+9 =