Steps to Create a WordPress Theme
Set Up Environment
Install WordPress locally using XAMPP, MAMP, or LocalWP.
Navigate to wp-content/themes/ and create a new theme folder (e.g., my-theme).
Create Essential Theme Files
style.css → Defines theme metadata.
index.php → Main template file.
header.php → Contains the site header.
footer.php → Contains the site footer.
functions.php → Registers theme features.
Define Theme Metadata in style.css
/*
Theme Name: My Custom Theme
Author: Your Name
Description: A simple custom WordPress theme.
Version: 1.0
*/
Build the Theme Structure
Use get_header() and get_footer() in index.php.
<?php get_header(); ?>
<main>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
<?php endwhile; endif; ?>
</main>
<?php get_footer(); ?>
Register Theme Features in functions.php
<?php
function my_theme_setup() {
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
register_nav_menus(['main-menu' => 'Main Menu']);
}
add_action('after_setup_theme', 'my_theme_setup');
?>