How Do I Create a Custom Content Type in WordPress?
If you’re looking to create a custom content type in WordPress, you can do so by following these steps:
First, create a new file in your WordPress theme’s directory (usually located at wp-content/themes/your_theme), and name it custom-content.php.
This file will serve as your content type’s template.
Next, add the following to your custom-content.php file:
__( ‘Custom Content Type’, ‘your_theme’ ), ‘singular_name’ => __( ‘Custom Content Type’, ‘your_theme’ ), ‘plural_name’ => __( ‘Custom Content Types’, ‘your_theme’ ), ‘parent_id’ => null, ‘parent_name’ => null, ‘depth’ => 1, ‘children’ => array( ‘content_type_1′ => array( ‘label’ => __( ‘Content Type 1′, ‘your_theme’ ), ‘singular_name’ => __( ‘Content Type 1′, ‘your_theme’ ), ‘plural_name’ => __( ‘Content Types’, ‘your_theme’ ), ‘parent_id’ => null, ‘parent_name’ => null, ‘depth’ => 1, ‘children’ => array( ‘content_type_2′ => array( ‘label’ => __( ‘Content Type 2′, ‘your_theme’ ), ‘singular_name’ => __( ‘Content Type 2′, ‘your_theme’ ), ‘plural_name’ => __( ‘Content Types’, ‘your_theme’ ), ‘parent_id’ => null, ‘parent_name’ => null, ‘depth’ => 1, ), ), ), ‘public’ => true, ‘publicly_queryable’ => true, ‘can_export’ => true, ‘exclude_from_search’ => true, ‘supports_rss’ => true, ‘capable_of_hierarchical_navigation’ => true, ‘comment_status’ => ‘open’, ‘ping_status’ => ‘open’, ‘menu_order’ => ‘0’, ‘posts_per_page’ => 100, ‘meta_box_type’ => ‘post’, ‘meta_box_key’ => ‘custom_content_type’, ‘meta_box_value’ => ‘Custom Content Type’, ‘taxonomy’ => ‘custom_content_type’, ‘slug’ => ‘custom-content-type’, ), );.
Now, you’ll need to add a post type for your custom content type. To do this, you’ll need to create a new file in your theme’s directory (usually located at wp-content/themes/your_theme), and name it custom-content-post. This file will serve as your content type’s post type.
Next, add the following to your custom-content-post.php file:
array( ‘name’ => __( ‘Custom Content Type’, ‘your_theme’ ), ‘singular_name’ => __( ‘Custom Content Type’, ‘your_theme’ ), ‘plural_name’ => __( ‘Custom Content Types’, ‘your_theme.