How to create a custom post in wordpress
Want to add custom content types to your WordPress site? Creating a custom post type allows you to organize and display unique content beyond regular posts and pages. Here’s a step-by-step guide to setting up a custom post in WordPress!

To create a custom post type in WordPress, you can use the register_post_type()
function. This function allows you to create a new post type and specify its labels, options, and capabilities.
Here’s an example of how you can use register_post_type()
to create a custom post type called “Books”:
function create_book_post_type() {
register_post_type( 'book',
array(
'labels' => array(
'name' => 'Books',
'singular_name' => 'Book',
'add_new' => 'Add New',
'add_new_item' => 'Add New Book',
'edit_item' => 'Edit Book',
'new_item' => 'New Book',
'view_item' => 'View Book',
'search_items' => 'Search Books',
'not_found' => 'No books found',
'not_found_in_trash' => 'No books found in Trash',
'parent_item_colon' => '',
'menu_name' => 'Books',
),
'public' => true,
'has_archive' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
'taxonomies' => array( 'category', 'post_tag' ),
'rewrite' => array( 'slug' => 'books' ),
)
);
}
add_action( 'init', 'create_book_post_type' );
This code creates a new function called create_book_post_type()
, which registers a new post type called “book” using the register_post_type()
function. It specifies a number of labels for the post type, such as the name, singular name, and various labels for the post type’s admin menu. It also sets the public
and has_archive
options to true
, which makes the post type visible to visitors and enables an archive page for the post type.
The ultimate WordPress page builder
Lifetime Access – $249 (1-time)
Divi is used by 974,872 customers who have given it over 23,000 5-star reviews. Why? Firstly, it’s the best (and easiest) way to build a WordPress website. Secondly, it’s cheaper than every competitor while offering unlimited website usage.
- Unlimited use
- Simple pricing
- Constant updates
- Rock solid security
- 24/7 Premium support
