full guide for creating a “Book” Custom Post Type (CPT) in WordPress
1. Register Book Custom Post Type
File: functions.php of your child theme (hello-elementor-child/functions.php)
✅ This creates a Book CPT with categories and tags enabled.
Create Frontend Page Template
If you want to show books in a custom layout using WP_Query:
File: template-books.php in your child theme (hello-elementor-child/template-books.php)
3.
Assign the Template to a Page
-
In WordPress admin → Pages → Add New → “All Books” (or any title).
-
On the right sidebar Page Attributes → Template, select Books Page.
-
Publish the page → visit it to see your book list.
Add Custom CSS
Since you already have custom/custom.css, add this for styling:
File: custom/custom.css
Make sure your child theme’s functions.php enqueues this CSS:
function hello_enqueue_custom_styles() {
wp_enqueue_style(
‘custom-style’,
get_stylesheet_directory_uri() . ‘/custom/custom.css’,
array(),
filemtime(get_stylesheet_directory() . ‘/custom/custom.css’)
);
}
add_action(‘wp_enqueue_scripts’, ‘hello_enqueue_custom_styles’);
Optional: Display Books by Category Only
You can modify the WP_Query in template-books.php to show a specific category:
$args = array(
‘post_type’ => ‘book’,
‘posts_per_page’ => -1,
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
‘category_name’ => ‘fiction’, // Replace with your category slug
);