DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
VGSOURCES
Get listed

block themesPATCH 2026.10.15

The Anatomy of a WordPress Theme Explained

By VGSources Team 9 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A WordPress theme is a coordinated set of files that determines how a site is structured and presented. At minimum, every theme has a root-level style.css; templates then define page markup, the template hierarchy selects the right template for each request, and functions.php supplies theme-specific behavior. Classic themes express templates in PHP, while block themes use HTML block markup and the Site Editor.

What a WordPress theme actually contains

WordPress describes themes as collections of files built with HTML, CSS and PHP, with JavaScript, configuration, templates, template parts, patterns and other assets added as a project requires. A theme is therefore more than a visual skin: it is the presentation layer that turns WordPress data into documents visitors can read and interact with.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The exact file list varies by theme. A small classic theme may have only a stylesheet, a few PHP templates and a functions file. A modern block theme may include HTML templates, reusable parts, block patterns, style variations and a theme.json configuration file. Optional directories such as assets/ and inc/ reflect the developer’s organization rather than a universal WordPress requirement.

The root directory

Theme files live in their own directory under the site’s themes directory. Files at the root commonly include style.css, functions.php and, for a classic theme, index.php. Block themes keep their fallback template in templates/index.html and normally also have parts/ and templates/ directories.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses | Anti UV Ray, For Computers & Gaming, Square Frame, Eyewear for Men and Women
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

style.css: the required identity and stylesheet file

style.css must be in the theme’s root directory. WordPress requires it for every theme, both to load CSS and to identify the theme in the Appearance/Themes interface. Its opening comment is a metadata header; WordPress reads fields such as the theme name, author and version from that comment when listing installed themes.

/*
Theme Name: Example Theme
Author: Example Author
Version: 1.0.0
*/

After the header, the file can contain ordinary CSS rules. In a classic theme, it commonly defines layout, typography, colors and responsive behavior. A block theme can also use it for global or custom CSS, while many of its site-wide settings are expressed through theme.json and block styles. The metadata comment must remain at the top; placing the file in assets/ or another subdirectory means WordPress will not recognize it as the theme’s required stylesheet.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Templates: files that create each page

Templates provide the document structure and output both static elements and dynamic WordPress content. They determine where a header, navigation, content area, sidebar, comments or footer appears, but the syntax depends on the theme architecture.

Classic PHP templates

Classic templates are PHP files containing HTML, PHP and WordPress template tags. Common root files include single.php for an individual post, page.php for a page, archive.php for archive listings and 404.php for a not-found response. Developers can call template tags to print titles, loop through posts, output navigation and include reusable pieces.

index.php is the required ultimate fallback for a classic theme. It can display a general post loop when no more specific template exists, although production themes normally provide more specialized files for important views.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Block HTML templates

Block themes represent templates as HTML files made from block markup rather than PHP template tags. Their files normally sit in templates/; for example, templates/single.html can describe an individual post and templates/page.html a page. Blocks such as the site logo, navigation, post title, post content and query loop are rendered by WordPress from the markup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A block theme’s required fallback is templates/index.html. The HTML extension does not mean the output is static: dynamic blocks still obtain titles, content, menus and other data at render time.

How the template hierarchy chooses a file

When a request arrives, WordPress first determines what kind of query it represents: a single post, a page, a category archive, a date archive, a search result, a 404 response and so on. It then checks the documented template filenames for that query type in order of specificity. The first matching file handles the request. If no specialized file exists, WordPress falls back through less-specific choices until it reaches the index template.

The same decision model applies to block themes, but it searches for .html templates in the block theme’s templates/ directory instead of PHP files. A child theme is checked before its parent, so a child file with the same recognized name overrides the matching parent template.

Practical examples

  • An individual post may use a post-type-specific single template first, then a general single.php in a classic theme (or its block equivalent), and eventually the index fallback.
  • A static page is matched against page-specific choices before a general page template and then the fallback.
  • A category archive can use a category-specific file, a broader taxonomy or archive template, and finally the index template if nothing more specific exists.
  • A missing URL reaches 404.php in a classic theme or the corresponding block template when one is present; otherwise the fallback handles it.

The filename is therefore part of the routing system. Editing a template that is not selected for the request will appear to have no effect, even when the code itself is valid.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men | Office Gifts for Women, iPhone Stand, Gadgets for Men, Office Decor, Gaming Desk Accessories for Samsung Fold 8, Switch, iPad
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Template parts: reusable headers, footers and sections

Template parts prevent the same markup from being copied into every template. Classic themes commonly use header.php, footer.php, sidebar.php and a template-parts/ directory. A PHP template includes these parts with the theme’s include functions, allowing one header change to affect every page that calls it.

Block themes put reusable pieces in parts/. A part can represent a header, footer, sidebar or any other repeated section and is inserted with block markup. The Site Editor can expose these parts for visual editing, while the same part remains available to multiple templates.

functions.php: behavior attached to the active theme

functions.php is loaded for the active theme. It is used to register hooks, declare theme support, enqueue CSS and JavaScript, define reusable functions and add other presentation-related behavior. It is not a universal site-functionality file: code placed there runs only while that theme is active.

<?php
function example_theme_setup() {
    add_theme_support( 'post-thumbnails' );
}
add_action( 'after_setup_theme', 'example_theme_setup' );

A child theme can have its own functions.php and add behavior without editing the parent file. Unlike template files, a child theme’s functions file is loaded in addition to the parent’s rather than replacing it, so functions must be named carefully and hooks must not be registered twice.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Features that should survive a theme change—such as custom post types, business rules or data-management integrations—belong in a plugin instead. Keeping durable functionality separate prevents a redesign from disabling essential site behavior.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Assets and supporting directories

CSS, JavaScript, fonts and images are usually grouped under assets/ in a classic theme, although WordPress does not require that exact directory. Custom PHP modules are often organized in inc/. Templates may remain in the root or be separated into a project-specific structure, provided the files are loaded correctly.

Block themes require the templates/ directory for block templates and commonly use parts/ for reusable sections. They may also include patterns/ for reusable block layouts and styles/ for style variations. These directories are optional unless a particular feature needs them. A block theme’s theme.json can define settings, presets and styles that WordPress exposes to blocks and the editor.

Classic themes versus block themes

Aspect Classic theme Block theme
Template representation PHP files containing HTML, PHP and template tags HTML files composed of WordPress block markup
Primary editing model Code-based editing with Customizer-era workflows and theme-specific controls Site Editor editing across supported site areas, alongside code editing
Required fallback index.php templates/index.html
Reusable components PHP includes such as header.php, footer.php and files in template-parts/ Block template parts stored in parts/
Configuration Conventional PHP and CSS setup, with support registered in code theme.json plus block settings and styles, with optional PHP and CSS

Block themes became available with WordPress 5.9. Their defining difference is not simply that they use HTML: they allow the Site Editor to change templates, template parts, styles and other site areas. Classic themes remain valid and continue to rely primarily on PHP templates, template tags, JavaScript and CSS.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Where to edit a theme safely

Use the Site Editor for block themes

With a block theme active, open the WordPress dashboard and choose Appearance > Editor. The Site Editor provides visual access to navigation, templates, template parts, styles and patterns that the theme exposes. Changes made there can be stored as user customizations, which may take precedence over the files shipped with the theme.

Use a child theme for code changes

For classic themes, create or activate a child theme before changing PHP or CSS. Put replacement templates in the child theme using the same recognized filename as the parent. WordPress will select the child version first, leaving the parent available for everything not overridden. Add child-specific behavior in the child functions.php rather than modifying the parent.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Edit files through a controlled development workflow

  1. Identify whether the active theme is classic or block-based and record the WordPress and theme versions.
  2. Back up the site and work in a staging or local copy, because a PHP syntax error can make the front end or dashboard unavailable.
  3. Find the selected template using the request type and hierarchy; do not assume that the file with the most obvious name is active.
  4. Make the smallest change in a child theme or version-controlled theme source. Enqueue styles and scripts through functions.php rather than hard-coding duplicate assets in templates.
  5. Test posts, pages, archives, search, navigation, responsive layouts and 404 responses, then check that editor changes and cached CSS are refreshed.

The built-in dashboard theme file editor is convenient for inspection but risky for production changes: it writes directly to live files and offers little recovery if a mistake causes a fatal error. Hosting file managers and deployment tools have the same risk unless a backup and rollback path exists.

Common anatomy mistakes and their fixes

The stylesheet is not recognized

Confirm that style.css is directly in the theme root and begins with a valid metadata comment. A stylesheet nested under assets/ can still be enqueued as CSS, but it cannot identify the theme by itself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A template edit does nothing

Check the request type, then trace the hierarchy from the most specific filename to the fallback. A child theme, a saved Site Editor customization or a plugin may be supplying the markup you are viewing. Inspect the rendered page and verify that caches are cleared after the correct file is changed.

A PHP error takes down the site

Restore the last known-good file from a backup or deployment revision, disable the child theme if necessary, and correct the syntax in a staging copy before reactivating it. Keep site-critical functionality in a plugin so changing themes does not remove it.

Changes disappear after a theme update

Direct edits to a parent theme are overwritten when the theme is updated. Move custom templates and styles into a child theme or maintain a properly versioned custom theme. For block themes, distinguish file changes from Site Editor customizations and document which layer owns each change.

A compact map of the files

File or directory Role Typical architecture
style.css Required root stylesheet and theme metadata All themes
functions.php Theme-scoped hooks, support declarations, functions and asset registration Classic and hybrid themes; optional in block themes
index.php Ultimate template fallback Classic themes
templates/index.html Ultimate block-template fallback Block themes
header.php, footer.php, sidebar.php Reusable PHP template parts Classic themes
template-parts/ Organized classic-theme partials Classic themes
parts/ Reusable block template parts Block themes
templates/ Block HTML templates selected by the hierarchy Block themes
patterns/ Reusable block layouts Common in block themes
styles/ Style variations Common in block themes
theme.json Block settings, presets and global styles Block themes and compatible themes
assets/, inc/ Project-organized assets and PHP modules Optional, often used by classic themes

The mental model to keep

Think of a theme as three cooperating layers. Templates and parts describe the page’s structure; CSS, block styles and assets control presentation; functions and configuration connect that structure to WordPress behavior. The hierarchy sits above the templates and decides which one receives a particular request. Once those layers are separated, diagnosing a visual problem becomes a matter of asking whether the wrong file was selected, the right markup was styled incorrectly, or theme-scoped behavior was never registered.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

block themesclassic themestemplate hierarchytheme developmentWordPress

Leave a reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.