{
  "id": 4531436,
  "title": "Using WP-CLI aliases to switch between multiple WordPress environments safely",
  "url": "https://urgent.news/2026/08/31/using-wp-cli-aliases-to-switch-between-multiple-wordpress",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-31T00:19:21.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/susumun/using-wp-cli-aliases-to-switch-between-multiple-wordpress-environments-safely-34a7"
  },
  "original_language": "en",
  "account": "Managing multiple WordPress environments can be a hassle, especially when it comes to typing out connection details and installation paths for each command. These errors are even more dangerous when running write commands, as they could potentially affect the wrong environment. WP-CLI offers a solution with its alias feature, which allows users to assign a short name like @production to a set of connection details, including SSH targets and WordPress install paths. Once registered, the short name replaces the full connection string for every subsequent command.\n\nThese aliases are typically stored in two config files: wp-cli.yml in the project directory or ~/.wp-cli/config.yml in the home directory. The project-level file takes precedence if the same alias exists in both. When working across multiple environments, it's better to consolidate aliases in the home directory to avoid confusion.\n\nTo use an alias, simply run the command with the alias name, like wp @production plugin list. WP-CLI will then execute the command against the remote WordPress install over SSH, just as if it had been run locally.\n\nFor single environments, individual aliases can be bundled into group aliases for easier execution. For example, @all can be used to run a command against both @production and @staging. This makes it easy to see which result belongs to which site, providing a form of record-keeping.\n\nHowever, when using aliases, it's important to keep a few things in mind. Name aliases so that the environment is obvious, and avoid using short forms that could become ambiguous. It's also a good practice to run wp cli alias list before executing anything unfamiliar to review the currently registered aliases and their targets. Finally, avoid running write commands through a group alias, as this could lead to unintended consequences if something goes wrong.",
  "summary": "Anyone managing several WordPress environments — production, staging, or separate installs for different languages — ends up re-typing SSH connection details and install paths every time they run a command. Building that connection string by hand each time invites mistakes: a copy-paste error, or reusing a stale path, can send a command to the wrong environment entirely. That risk matters most…",
  "key_points": [
    "WP-CLI aliases simplify managing multiple WordPress environments.",
    "Aliases store connection details in wp-cli.yml or ~/.wp-cli/config.yml.",
    "Use wp @environment command to execute against specific WordPress install."
  ],
  "editors_take": "WP-CLI's alias feature simplifies managing multiple WordPress environments by letting users substitute lengthy connection details with short names, reducing errors when running commands across different sites.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}