Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beginners documentation > added #478

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 24 additions & 0 deletions bin/handbook-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,30 @@
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/main\/tools.md",
"parent": null
},
"for-beginners": {
"title": "For Beginners",
"slug": "for-beginners",
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/main\/for-beginners.md",
"parent": "for-beginners"
},
"for-beginners-conntect-ssh": {
"title": "SSH Setup for WordPress CLI",
"slug": "conntect-ssh",
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/main\/for-beginners-conntect-ssh.md",
"parent": "for-beginners"
},
"for-beginners-save-commands-in-cli": {
"title": "Saving Commands in WordPress CLI",
"slug": "save-commands-in-cli",
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/main\/for-beginners-save-commands-in-cli.md",
"parent": "for-beginners"
},
"for-beginners-save-commands-in-terminal": {
"title": "Saving Commands in Terminal",
"slug": "save-commands-in-terminal",
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/main\/for-beginners-save-commands-in-terminal.md",
"parent": "for-beginners"
},
"troubleshooting": {
"title": "Troubleshooting Guide",
"slug": "troubleshooting",
Expand Down
81 changes: 81 additions & 0 deletions for-beginners-conntect-ssh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# SSH Setup for WordPress CLI

This quick start guide will walk you through the process of setting up SSH for the WordPress CLI (WP-CLI) on your server. Using SSH authentication with WP-CLI allows you to securely manage your WordPress installations from the command line.

## Prerequisites

- **WordPress:** Ensure you have a WordPress installation on your server.
- **WP-CLI:** Follow the installation steps from the [WP-CLI Quick Start Guide](#wordpress-cli-wp-cli-quick-start-guide).

## SSH Key Generation

1. **Generate SSH Key Pair:**
If you don't have an SSH key pair, generate one using the following command:

```bash
ssh-keygen -t rsa -b 4096 -C "[email protected]"
```

Follow the prompts to set a location for the key pair (press Enter for the default), and set a passphrase for added security.

2. **Start SSH Agent:**
Start the SSH agent to manage your keys:

```bash
eval "$(ssh-agent -s)"
```

3. **Add SSH Private Key:**
Add your SSH private key to the SSH agent:

```bash
ssh-add ~/.ssh/id_rsa
```

If you used a different file name for your key pair, replace `id_rsa` with the actual file name.

## WordPress SSH Configuration

1. **Edit `wp-config.php`:**
Open the `wp-config.php` file of your WordPress installation:

```bash
nano /path/to/your/wordpress/wp-config.php
```

2. **Add SSH Configurations:**
Add the following lines to the `wp-config.php` file, replacing the placeholders with your actual SSH key file paths:

```php
define('FS_METHOD', 'ssh2');
define('FTP_PUBKEY', '/path/to/your/.ssh/id_rsa.pub');
define('FTP_PRIKEY', '/path/to/your/.ssh/id_rsa');
define('FTP_USER', 'your-ssh-username');
define('FTP_HOST', 'your-server-hostname-or-ip');
```

Save and exit the editor.

## Testing SSH Connection

1. **Test Connection:**
Test the SSH connection to your server using the following command:

```bash
ssh -T your-ssh-username@your-server-hostname-or-ip
```

Replace `your-ssh-username` and `your-server-hostname-or-ip` with your actual SSH username and server details.

If prompted, type "yes" to add the server to your list of known hosts.

2. **Verify WP-CLI Connection:**
Confirm that WP-CLI is configured to use SSH:

```bash
wp core check-update
```

If everything is set up correctly, this command should check for available WordPress updates.

Congratulations! You have successfully set up SSH for the WordPress CLI. You can now securely manage your WordPress installations using WP-CLI from the command line.
81 changes: 81 additions & 0 deletions for-beginners-save-commands-in-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Saving Commands in WordPress CLI

## Overview

This quick start guide will guide you through the process of saving and managing custom commands in the WordPress CLI (WP-CLI). Saving commands can help streamline your workflow and make it easier to execute complex or frequently used tasks.

## Prerequisites

Ensure that you have WP-CLI installed on your system. If not, refer to the [WP-CLI Quick Start Guide](#wordpress-cli-wp-cli-quick-start-guide) for installation instructions.

## Saving Commands in `wp-cli.yml`

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:

```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:
mycommand:
run:
- plugin activate my-plugin
- theme activate my-theme
```

Save and exit the editor.

4. **Run Custom Commands:**
Execute your custom command using the `wp` command:

```bash
wp mycommand
```

This will activate the specified plugin and theme.

## Additional Tips

### Using Variables

You can use variables in your custom commands for better flexibility. For example:

```yaml
commands:
activate-plugin:
run:
- plugin activate %s
```

Run the command with a plugin slug:

```bash
wp activate-plugin my-plugin
```

### Organizing Commands

Group related commands by using subcommands. For instance:

```yaml
commands:
theme:
run:
- theme activate %s
- theme update %s
```

Run the subcommands:

```bash
wp theme activate my-theme
wp theme update my-theme
```
61 changes: 61 additions & 0 deletions for-beginners-save-commands-in-terminal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Saving Commands in Terminal

Saving commands can save you time and reduce the likelihood of errors, especially for complex or frequently executed tasks.

### Using Shell Aliases

1. **Open Your Shell Configuration File:**
Open the configuration file for your shell (e.g., `~/.bashrc` for Bash) using a text editor:

```bash
nano ~/.bashrc
```

2. **Create an Alias:**
Add a new alias to the file. For example, to create an alias for a WordPress CLI update command:

```bash
alias wpupdate='wp core update --path=/path/to/your/wordpress'
```

Save and exit the editor.

3. **Reload Shell Configuration:**
Reload the shell configuration for the changes to take effect:

```bash
source ~/.bashrc
```

4. **Use the Alias:**
Now you can use your alias like a regular command:

```bash
wpupdate
```

### Using Shell Functions

1. **Open Your Shell Configuration File:**
Open the configuration file for your shell.

2. **Create a Shell Function:**
Add a new shell function to the file. For example:

```bash
function wpupdate() {
wp core update --path=/path/to/your/wordpress
}
```

Save and exit the editor.

3. **Reload Shell Configuration:**
Reload the shell configuration for the changes to take effect.

4. **Use the Function:**
Now you can use your shell function:

```bash
wpupdate
```
76 changes: 76 additions & 0 deletions for-beginners.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Starter Guide for the WordPress CLI

Welcome to the WordPress Command Line Interface (CLI) Quick Start Guide! If you're not a tech expert but want to explore the power of managing your WordPress site from the command line, you're in the right place. The CLI can help you perform various tasks more efficiently. Let's get started!

## What is the WordPress CLI?

The WordPress CLI is a powerful tool that allows you to manage your WordPress site from the command line. It's like giving your website superpowers, enabling you to perform tasks quickly and effortlessly.

## Prerequisites

1. **Access to Command Line Interface (CLI):**
- If you're using a hosting service, make sure they provide SSH access or a web-based terminal.
- If you're managing your server, ensure you have command line access.

2. **WordPress Installed:**
- Make sure your WordPress site is up and running.

## Installation (If not already installed)

1. **Connect to your server:**
- Use SSH or access your server through the web-based terminal.

2. **Install WP-CLI:**
- Follow the installation instructions provided on the [official WP-CLI website](https://wp-cli.org/).

## Basic Commands

1. **Check WordPress Version:**
```bash
wp core version
```

2. **Update WordPress:**
```bash
wp core update
```

3. **Install Plugin:**
```bash
wp plugin install <plugin-name>
```

4. **Activate Plugin:**
```bash
wp plugin activate <plugin-name>
```

5. **List Installed Plugins:**
```bash
wp plugin list
```

## Common Tasks

1. **Create a New Post:**
```bash
wp post create --post_type=post --post_title='Your Post Title' --post_content='Your post content.'
```

2. **Update Theme:**
```bash
wp theme update <theme-name>
```

3. **Search for Themes:**
```bash
wp theme search <keyword>
```

## Troubleshooting

1. **Errors or Issues:**
- If you encounter errors, refer to the [WP-CLI Handbook](https://make.wordpress.org/cli/handbook/) or seek help from your hosting support.

2. **Backup Your Site:**
- Before making significant changes, always backup your WordPress site.
10 changes: 9 additions & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ Can’t find what you’re looking for? [Open an issue](https://github.com/wp-cl
* **[Force output to a specific locale](https://make.wordpress.org/cli/handbook/guides/force-output-specific-locale/)** - Localisation issue
* **[Identify a Plugin or Theme Conflict](https://make.wordpress.org/cli/handbook/guides/identify-plugin-theme-conflict/)** - Debugging advise
* **[Sharing WP-CLI Packages](https://make.wordpress.org/cli/handbook/guides/sharing-wp-cli-packages/)** - Some words about your environment
* **[Troubleshooting Guide](https://make.wordpress.org/cli/handbook/guides/troubleshooting/)** - Some help to troubleshoot
* **[Troubleshooting Guide](https://make.wordpress.org/cli/handbook/guides/troubleshooting/)** - Some help to
troubleshoot

## For Beginners

* **[Quick Start](https://make.wordpress.org/cli/handbook/for-beginners)** - Quick Start documentation for beginners into WordPress CLI.
* **[SSH Configuration](https://make.wordpress.org/cli/handbook/for-beginners/conntect-ssh/)** - Documentation how to setup your SSH Environment.
* **[Save Commands in WP-CLI](https://make.wordpress.org/cli/handbook/for-beginners/save-commands-in-cli/)** - Quick Starter documentation how to save your Commands in the WordPress CLI.
* **[Save Commands in your Terminal](https://make.wordpress.org/cli/handbook/for-beginners/save-commands-in-terminal/)** - Documentation how to save your Commands in your Terminal.

## References

Expand Down