Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Edit wp search-replace example to fit others; remove custom command
  • Loading branch information
danielbachhuber committed Jun 13, 2024
commit f74dec99ffff02194153bcc86b40929c6585b507
48 changes: 9 additions & 39 deletions quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,50 +125,20 @@ Found 1 image to regenerate.
Success: Finished regenerating the image.
```

Wondering what's next? Browse through [all of WP-CLI's commands](https://developer.wordpress.org/cli/commands/) to explore your new world. Or, catch up with [shell friends](https://make.wordpress.org/cli/handbook/shell-friends/) to learn about helpful command line utilities.
**Search and replace URLs**

If you're moving a database from one domain to another, `wp search-replace` ([doc](https://developer.wordpress.org/cli/commands/search-replace/)) makes it easy to update all URL references in your database.

**Search and Replace Links**
To see which links will be replaced in your database, use the --dry-run flag:

1. Navigate to Your WordPress Project:
Open a terminal and navigate to the root directory of your WordPress project.

2. Preview Changes (Optional)
To see which links will be replaced in your database, use the --dry-run flag:
```bash
wp search-replace 'http://oldsite.com' 'http://newsite.com' --dry-run
```

3. Replace Links:
When ready to replace the links, run:

```bash
wp search-replace 'http://oldsite.com' 'http://newsite.com'
wp search-replace 'http://oldsite.com' 'http://newsite.com' --dry-run
```

**Adding New Commands**

1. Navigate to Your WordPress Project:
Open a terminal and navigate to the root directory of your WordPress project.

2. Create or Open `wp-cli.yml`:**
Use a text editor to create or open the `wp-cli.yml` configuration file:
When ready to replace the links, run:

```bash
nano wp-cli.yml
```

3. Add Custom Commands:
Inside the `wp-cli.yml` file, under the `commands` section, add your custom commands. For example:

```yaml
commands:
yournewcommand:
run:
- plugin activate my-plugin
- theme activate my-theme
```

4. Save and exit the editor.
```
wp search-replace 'http://oldsite.com' 'http://newsite.com'
```

For more detailed information about WP-CLI commands, visit the [WP-CLI Commands Cookbook](https://make.wordpress.org/cli/handbook/guides/commands-cookbook/).
Wondering what's next? Browse through [all of WP-CLI's commands](https://developer.wordpress.org/cli/commands/) to explore your new world. For more detailed information about creating custom commands, visit the [WP-CLI Commands Cookbook](https://make.wordpress.org/cli/handbook/guides/commands-cookbook/). Or, catch up with [shell friends](https://make.wordpress.org/cli/handbook/shell-friends/) to learn about helpful command line utilities.