Last active
January 3, 2020 19:54
-
-
Save vanaf1979/d9430a03de0adbbb876e4de603e8d59a to your computer and use it in GitHub Desktop.
Create a custom post type gist for my WordPress: tutorial "Multiple Custom Templates for Posts and Custom Post Types" at https://since1979.dev/wordpress-multiple-custom-templates-for-posts-and-custom-post-types/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function create_product_post_type() { | |
register_post_type( 'product', | |
array( | |
'labels' => array( | |
'name' => __( 'Products' ), | |
'singular_name' => __( 'Product' ) | |
), | |
'public' => true, | |
'has_archive' => true, | |
'show_in_rest' => true // To enable Gutenberg. | |
) | |
); | |
} | |
add_action( 'init', 'create_product_post_type' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment