How to Register a Custom Post Type in WordPress (Step-by-Step)
The complete register_post_type() walkthrough, including the rewrite-rules gotcha that causes a confusing 404 every time.
Page builders are fine for quick sites, but a genuinely custom WordPress theme — built from actual template files — is still the right choice when performance, precise design control, or long-term maintainability matter. Here's the real process.
style.css — must contain a theme header comment (name, version, author)
index.php — the universal fallback template
functions.php — theme setup and feature registration
Technically that's a complete, activatable theme — everything else is refinement.
function mytheme_setup() {
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
add_theme_support('html5', ['search-form', 'comment-form']);
register_nav_menus(['primary' => 'Primary Menu']);
}
add_action('after_setup_theme', 'mytheme_setup');
WordPress picks a template file based on a specific, well-defined priority order. The most common ones you'll actually create:
front-page.php — the homepage specificallysingle.php — an individual blog postpage.php — a static pagearchive.php — a category/tag/date archive listingheader.php / footer.php — shared partials, included via get_header()/get_footer()Every template that displays post content runs "the Loop" — WordPress's core content-rendering pattern:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; endif; ?>
function mytheme_scripts() {
wp_enqueue_style('mytheme-style', get_stylesheet_uri());
wp_enqueue_script('mytheme-main', get_template_directory_uri() . '/js/main.js', [], '1.0', true);
}
add_action('wp_enqueue_scripts', 'mytheme_scripts');
Never hardcode <link>/<script> tags directly in header.php — wp_enqueue_* lets WordPress manage dependencies and avoid loading the same script twice.
From here, it's mostly building out template files for your specific content types — the foundation above is genuinely the entire skeleton every WordPress theme, however complex, is built on.
The complete register_post_type() walkthrough, including the rewrite-rules gotcha that causes a confusing 404 every time.
Field groups, repeaters, displaying ACF data in templates, and registering fields in code so they ship with your theme.
Actions vs filters, safe functions.php structure, and the defensive habits that keep a single typo from taking down your site.