Set Up a Testing Environment

To test WordPress coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. tickets effectively, you need an environment where you can apply patches and run tests. Patches are created against the trunk branch, the development version of WordPress, not the stable release from wordpress.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org//download, so you’ll need to work with the development codebase. This guide covers the options available for setting up a testing environment.

Choose Your Environment

There are two main ways to test WordPress core tickets:

  1. WordPress Playground (Browser-based): Best for quick visual testing and verifying patches without installing anything on your computer.
  2. Local Development Environment: Required for more advanced testing, running automated tests (PHPUnit, e2e), and working with complex patches or build tools.

When to use Playground?

  • You need to quickly verify a visual change or a bug fix.
  • You cannot or do not want to install software on your computer.
  • The ticket has a Pull Request (PR) or a ZIP file that Playground can load.

Learn how to use Playground for testing

When to use a Local Environment?

  • You need to use command-line tools like grunt or git.
  • You want to run automated test suites (PHPUnit, end-to-end tests).
  • You are developing a patch or working on a complex feature that requires a persistent environment.

Setting Up a Local Environment

The recommended way to set up a local environment for WordPress core development is using Docker.

Prerequisites

Before you begin, ensure you have the following installed on your computer:
1. Node.js: Version 20.x or later.
2. npm: Version 10.x or later (usually comes with Node.js).
3. GitGit Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. Most modern plugin and theme development is being done with this version control system. https://git-scm.com/: For version control.
4. Docker Desktop (or a compatible container runtime like OrbStack, Colima, or Rancher Desktop).

Setup Instructions

Prefer a video walkthrough?
Follow along with this step-by-step setup guide as you work through the instructions below.

  1. Fork and Clone the Repository
    Fork the WordPress/wordpress-develop repository to your GitHubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged by the repository owner. https://github.com/ account, then clone it locally:

    git clone https://github.com/YOUR_USERNAME/wordpress-develop.git
    cd wordpress-develop
    git remote add upstream https://github.com/WordPress/wordpress-develop.git
    

    Adding the upstream remote allows you to keep your local repository in sync with the latest changes from WordPress core.

  2. Install Dependencies
    Run the following command to install the necessary JavaScriptJavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com and PHPPHP PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. https://www.php.net/manual/en/preface.php tools:

    npm install
    
  3. Build WordPress
    Compile the source files into a running WordPress instance:

    npm run build:dev
    
  4. Start the Environment
    Ensure Docker Desktop is running, then start the Docker environment:

    npm run env:start
    
  5. Install WordPress
    Run the installation script to set up the database and site:

    npm run env:install
    

Your local WordPress site should now be accessible at `http://localhost:8889`.

  • Username: admin
  • Password: password

Common Commands

  • Start environment: npm run env:start
  • Stop environment: npm run env:stop
  • Reset environment: npm run env:reset (Warning: deletes database)
  • Run WP-CLIWP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/ https://make.wordpress.org/cli/ commands: npm run env:cli -- <command> (e.g., npm run env:cli -- user list)

Next Steps

Now that your local environment is set up, learn how to apply patches and run tests:

Resources

s
search
c
compose new post
r
reply
e
edit
t
go to top
j
go to the next post or comment
k
go to the previous post or comment
o
toggle comment visibility
esc
cancel edit post or comment