SponsoredHosinger Special Offer

WP WordPress Theme Development

Build classic and block WordPress themes from scratch: the template hierarchy, The Loop, the_title() and the_content(), template parts, menus, the Customizer, child themes and theme.json.

Setting Up a Local WordPress Environment

WordPress Theme Development Lesson 2 of 30 ~3 min read

Overview

Build themes on a local copy of WordPress running on your own computer, with debugging switched on, so mistakes show up as clear error messages instead of a blank white page on a live site.

Choose a local environment

ToolGood forNotes
LocalWPBeginners and freelancersOne-click WordPress sites, built-in SSL and email catcher.
XAMPP / MAMPIf you already use them for PHPInstall WordPress manually into htdocs.
wp-envDevelopers comfortable with Dockernpx @wordpress/env start — what core contributors use.
WordPress StudioFast local sites on macOS and WindowsFree, by Automattic.

Any of them is fine. What matters is that you have a running site, access to its files, and the ability to edit wp-config.php.

Turn on debugging

Open wp-config.php in the site root and find the line define( 'WP_DEBUG', false );. Replace it with the block below. Put it above the line that says "That's all, stop editing!".

// Show every PHP warning and notice while developing.
define( 'WP_DEBUG', true );

// Write them to wp-content/debug.log as well...
define( 'WP_DEBUG_LOG', true );

// ...but don't print them into the page HTML, where they break layouts.
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

// Load unminified core CSS and JS so browser errors point at readable code.
define( 'SCRIPT_DEBUG', true );

Now every notice your theme triggers lands in wp-content/debug.log. Keep that file open while you work — a good theme produces zero notices.

Watch out: Never leave WP_DEBUG on a production site. Notices can leak file paths and database details to visitors.

Create the theme folder

Themes live in wp-content/themes/. Each theme is one folder. Create the folder for the theme you will build throughout this path:

cd wp-content/themes
mkdir gdc-starter
cd gdc-starter

The folder name becomes the theme's slug. Use lowercase letters, numbers and hyphens only. It is also the name WordPress stores in the database to remember which theme is active, so do not rename it once a site is using it.

Install test content

An empty site hides bugs. Your theme has to cope with very long titles, posts with no featured image, nested comments, sticky posts and images of every shape. Import the official Theme Unit Test data:

  1. Download the XML file from the theme-test-data repository.
  2. In the dashboard, go to Tools → Import → WordPress and install the importer.
  3. Upload the XML file and tick "Download and import file attachments".
Tip: Also install the Query Monitor plugin. It shows which template file rendered the current page, every database query, and every hook — you will use it constantly from lesson 5 onwards.

Practice

  • Get a local site running and confirm you can reach the dashboard.
  • Enable the debug constants and confirm wp-content/debug.log appears after you visit a page with a deliberate typo in a plugin.
  • Create the empty gdc-starter folder. In the next lesson you will make WordPress recognise it.
Create a free account to save which lessons you've finished. Save my progress