๐ฏ By the end of this lesson you canโฆ
- Write a valid style.css header
- Create index.php
- Use functions.php to add features
๐จ CSS
wp-content/themes/sunrise/style.css
1/*2Theme Name: Sunrise3Author: Your Name4Description: A bright, simple blog theme.5Version: 1.0.06Requires at least: 6.47Text Domain: sunrise8*/9body { font-family: system-ui, sans-serif; line-height: 1.6; }
๐ PHP
wp-content/themes/sunrise/index.php
๐ Tap a line to explain it
1<!doctype html>2<html <?php language_attributes(); ?>>3<head>4 <meta charset="<?php bloginfo( 'charset' ); ?>">5 <?php wp_head(); ?>6</head>7<body <?php body_class(); ?>>8 <h1><?php bloginfo( 'name' ); ?></h1>9 <?php while ( have_posts() ) : the_post(); ?>10 <h2><?php the_title(); ?></h2>11 <?php endwhile; ?>12 <?php wp_footer(); ?>13</body>14</html>
๐ WordPress PHP
functions.php
๐ Tap a line to explain it
1<?php2add_action( 'after_setup_theme', function () {3 add_theme_support( 'title-tag' );4 add_theme_support( 'post-thumbnails' );5 register_nav_menus( [ 'primary' => 'Primary menu' ] );6} );7 8do_action( 'after_setup_theme' ); // (WordPress does this for you โ we trigger it to see the result)9var_dump( current_theme_supports( 'post-thumbnails' ) );
| File | Purpose |
|---|---|
style.css | theme details + main styles (required) |
index.php | fallback template (required) |
functions.php | setup: supports, menus, enqueues |
header.php / footer.php | shared top and bottom |
single.php, page.php, archive.php | specific templates |
screenshot.png | 1200ร900 preview in Appearance โ Themes |
๐ก Concept check
What makes WordPress recognise a folder as a theme?
๐ Key takeaways
style.cssmust start with a comment containingTheme Name:.index.phpis the fallback template for everything.functions.phpruns on every request โ itโs the themeโs setup file.
Finished reading & practising?
Saved in this browser. Create a free account to keep it forever.