Concise checklist and reference for building a custom WordPress theme.
style.cssscreenshot.png (1200 × 900)index.phpheader.phpfooter.phpfunctions.phpsass/ folder for SCSSjs/ folder for JavaScript filesimages/ folder for website assetshooks/ folder (organize by purpose):
init.php — Load site content such as menus, etc.
if (!defined('ABSPATH')) {
header("Location: /");
}
add_action('init', 'hma_init');
function hma_init()
{
register_nav_menus([
'primary-menu' => __('Primary Menu'),
'quick-links' => __('Quick Links'),
]);
if (function_exists('acf_add_options_page')) {
acf_add_options_page(
array(
'page_title' => get_bloginfo('name') . ' Theme Options',
'menu_title' => get_bloginfo('name') . ' Theme Options',
'menu_slug' => 'theme-options',
'capability' => 'edit_posts',
'redirect' => false,
'icon_url' => get_template_directory_uri() . '/images/favicon.png',
)
);
}
}
after_setup_theme.php — Add theme supports via after_setup_theme hook:
<?php
if (!defined('ABSPATH')) {
header("Location: /");
}
add_action('after_setup_theme', 'dst_after_setup_theme');
function dst_after_setup_theme()
{
$theme_support_arr = [
'menus',
'post-thumbnails',
'title-tag',
'comment-form',
'comment-list',
'custom-fields',
'custom-logo',
];
foreach ($theme_support_arr as $heme_support) {
add_theme_support($heme_support);
}
}
wp_enqueue_scripts.php — Enqueue Styles/Scripts/Localization files.
/**
* Enqueue Styles, Scripts, and Localization in WordPress
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function mytheme_enqueue_assets() {
/**
* 1. Enqueue Styles
*/
wp_enqueue_style(
'mytheme-main-style', // Handle
get_stylesheet_directory_uri() . '/assets/css/main.css', // File URL
array(), // Dependencies
filemtime( get_stylesheet_directory() . '/assets/css/main.css' ) // Version (cache busting)
);
/**
* 2. Enqueue Scripts
*/
wp_enqueue_script(
'mytheme-main-script', // Handle
get_stylesheet_directory_uri() . '/assets/js/main.js', // File URL
array( 'jquery' ), // Dependencies
filemtime( get_stylesheet_directory() . '/assets/js/main.js' ), // Version
true // Load in footer
);
/**
* 3. Localize (Pass PHP data to JS)
*/
wp_localize_script(
'mytheme-main-script', // Script handle (must match enqueued script)
'mythemeVars', // JS global variable
array(
'ajax_url' => admin_url( 'admin-ajax.php' ), // Example: for AJAX
'site_url' => get_site_url(),
'greeting' => __( 'Hello from PHP!', 'mytheme' ),
)
);
/**
* 4. Enqueue WordPress built-in jQuery (optional, if not already loaded)
*/
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_assets' );
index.php and include all action .php files in
index.php.
:root {
--heading-font-size: 3.75rem;//3.75rem = 60px
--heading-font-weight: 700;
}
h1 {
font-size: var(--heading-font-size);
font-weight: var(--Heading-font-weight);
}
:root {
--sub-heading-font-size: 2.1875rem;// 2.1875rem = 35px
--sub-heading-font-weight:500;
}
h2,h3,h4,h5,h6 {
font-size: var(--sub-heading-font-size);
font-weight: var(--sub-Heading-font-weight);
}
:root {
--description-font-size: 0.875rem;// 0.875rem = 14px
--description-font-weight:500;
}
p {
font-size: var(--description-font-size);
font-weight: var(--description-font-weight);
}
:root {
--heading-font-color: red;
--sub-heading-font-color: green;
--description-font-color:yellow;
}
.heading{
color: var(--heading-font-color);
}
.sub-heading{
color: var(--sub-heading-font-color);
}
.description{
color: var(--description-font-color);
}
.dst-btn{
padding:1.5rem;
font-size:1.2rem;
font-weight:500;
border:1px solid transparent;
border-radius: .5rem;
}
.dst-bth-1{
background-color:yellow;
color: green;
}
.dst-bth-1:hover{
background-color:green;
color: yellow;
}
1- use class "dst-btn" for website buttons
2- use class "dst-bth-1" for website buttons color
3- use class "dst-bth-1:hover" for website buttons hover color
Note : Create more classes for any different style buttons and use accordingly