LESSON 02 / 04

Theme Anatomy

A theme needs only two files to exist: style.css (with a header comment) and index.php. Add functions.php, screenshot.png and templates as you grow.

๐ŸŽ“Mediumlevel
โฑ๏ธ35 minto finish
โœ๏ธ1activities

๐Ÿ“‚ How Themes Work๐Ÿท๏ธ WordPress

๐ŸŽฏ 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' ) );
Common theme files
FilePurpose
style.csstheme details + main styles (required)
index.phpfallback template (required)
functions.phpsetup: supports, menus, enqueues
header.php / footer.phpshared top and bottom
single.php, page.php, archive.phpspecific templates
screenshot.png1200ร—900 preview in Appearance โ†’ Themes
๐Ÿ’ก Concept check
What makes WordPress recognise a folder as a theme?

๐Ÿ“Œ Key takeaways

  • style.css must start with a comment containing Theme Name:.
  • index.php is the fallback template for everything.
  • functions.php runs 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.