Ask any question about WordPress here... and get an instant response.
Post this Question & Answer:
How can I implement custom post types without using a plugin?
Asked on Mar 22, 2026
Answer
To implement custom post types in WordPress without using a plugin, you can add code to your theme's `functions.php` file. This involves using the `register_post_type` function, which allows you to define and register new post types.
<!-- BEGIN COPY / PASTE -->
function my_custom_post_type() {
$args = array(
'labels' => array(
'name' => 'Books',
'singular_name' => 'Book'
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'books'),
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type('book', $args);
}
add_action('init', 'my_custom_post_type');
<!-- END COPY / PASTE -->Additional Comment:
- Ensure you add this code to a child theme's `functions.php` to prevent losing changes during theme updates.
- After registering a new post type, you may need to refresh your permalinks by visiting Settings → Permalinks and clicking "Save Changes".
- Custom post types can be customized further with additional arguments in the `$args` array.
Recommended Links:
