$npx -y skills add jezweb/claude-skills --skill wordpress-setupConnect to a WordPress site via WP-CLI over SSH or the REST API. Check CLI, test SSH, set up auth, verify access, save config. Use whenever the user wants to connect to a WordPress site, set up WP-CLI access, create an Application Password, or troubleshoot WordPress connection /
| 1 | # WordPress Setup |
| 2 | |
| 3 | Connect to a WordPress site and verify working access via WP-CLI or REST API. Produces a verified connection config ready for content management and Elementor editing. |
| 4 | |
| 5 | ## Workflow |
| 6 | |
| 7 | ### Step 1: Check WP-CLI |
| 8 | |
| 9 | ```bash |
| 10 | wp --version |
| 11 | ``` |
| 12 | |
| 13 | If not installed, guide the user: |
| 14 | |
| 15 | ```bash |
| 16 | # macOS/Linux |
| 17 | curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar |
| 18 | chmod +x wp-cli.phar |
| 19 | sudo mv wp-cli.phar /usr/local/bin/wp |
| 20 | ``` |
| 21 | |
| 22 | Also ensure the SSH extension is available (needed for remote sites): |
| 23 | |
| 24 | ```bash |
| 25 | wp package install wp-cli/ssh-command |
| 26 | ``` |
| 27 | |
| 28 | ### Step 2: Connect to the Site |
| 29 | |
| 30 | **Option A: WP-CLI over SSH (preferred)** |
| 31 | |
| 32 | ```bash |
| 33 | wp --ssh=user@hostname/path/to/wordpress option get siteurl |
| 34 | ``` |
| 35 | |
| 36 | Common patterns: |
| 37 | - Rocket.net: `wp --ssh=user@hostname/www/sitename/public option get siteurl` |
| 38 | - cPanel: `wp --ssh=user@hostname/public_html option get siteurl` |
| 39 | - Custom: Ask user for SSH user, host, and WordPress path |
| 40 | |
| 41 | Test with a simple command first: |
| 42 | |
| 43 | ```bash |
| 44 | wp --ssh=user@host/path core version |
| 45 | ``` |
| 46 | |
| 47 | **Option B: REST API with Application Password** |
| 48 | |
| 49 | If SSH isn't available: |
| 50 | |
| 51 | 1. Navigate to `https://example.com/wp-admin/profile.php` (or use browser automation) |
| 52 | 2. Scroll to "Application Passwords" section |
| 53 | 3. Enter a name (e.g. "Claude Code") and click "Add New Application Password" |
| 54 | 4. Copy the generated password (spaces are part of it but optional in auth) |
| 55 | |
| 56 | Test the connection: |
| 57 | |
| 58 | ```bash |
| 59 | curl -s https://example.com/wp-json/wp/v2/posts?per_page=1 \ |
| 60 | -u "username:xxxx xxxx xxxx xxxx xxxx xxxx" | jq '.[0].title' |
| 61 | ``` |
| 62 | |
| 63 | ### Step 3: Store Credentials |
| 64 | |
| 65 | **For WP-CLI SSH** — create a `wp-cli.yml` in the project root: |
| 66 | |
| 67 | ```yaml |
| 68 | ssh: |
| 69 | sitename: |
| 70 | cmd: ssh -o StrictHostKeyChecking=no %pseudotty% user@hostname %cmd% |
| 71 | url: /path/to/wordpress |
| 72 | ``` |
| 73 | |
| 74 | Then use: `wp @sitename option get siteurl` |
| 75 | |
| 76 | **For REST API** — store in `.dev.vars`: |
| 77 | |
| 78 | ``` |
| 79 | WP_SITE_URL=https://example.com |
| 80 | WP_USERNAME=admin |
| 81 | WP_APP_PASSWORD=xxxx xxxx xxxx xxxx xxxx xxxx |
| 82 | ``` |
| 83 | |
| 84 | Ensure `.dev.vars` is in `.gitignore`. For cross-project use, store in your preferred secrets manager (environment variable, 1Password CLI, etc.). |
| 85 | |
| 86 | ### Step 4: Verify Full Access |
| 87 | |
| 88 | Run a comprehensive check: |
| 89 | |
| 90 | ```bash |
| 91 | # Site info |
| 92 | wp @sitename option get siteurl |
| 93 | wp @sitename option get blogname |
| 94 | |
| 95 | # Content access |
| 96 | wp @sitename post list --post_type=page --posts_per_page=5 --fields=ID,post_title,post_status |
| 97 | |
| 98 | # Plugin status (check for Elementor) |
| 99 | wp @sitename plugin status elementor |
| 100 | |
| 101 | # Theme info |
| 102 | wp @sitename theme status |
| 103 | ``` |
| 104 | |
| 105 | ### Step 5: Save Site Config |
| 106 | |
| 107 | Create `wordpress.config.json` for other skills to reference: |
| 108 | |
| 109 | ```json |
| 110 | { |
| 111 | "site": "example.com", |
| 112 | "siteUrl": "https://example.com", |
| 113 | "accessMethod": "ssh", |
| 114 | "sshAlias": "sitename", |
| 115 | "wpPath": "/path/to/wordpress", |
| 116 | "hasElementor": true, |
| 117 | "elementorVersion": "3.x.x" |
| 118 | } |
| 119 | ``` |
| 120 | |
| 121 | --- |
| 122 | |
| 123 | ## Critical Patterns |
| 124 | |
| 125 | ### SSH Connection Issues |
| 126 | |
| 127 | | Symptom | Fix | |
| 128 | |---------|-----| |
| 129 | | `Permission denied (publickey)` | Check SSH key: `ssh -v user@host` | |
| 130 | | `wp: command not found` via SSH | WP-CLI not in remote PATH — use full path: `/usr/local/bin/wp` | |
| 131 | | `Error: This does not appear to be a WordPress installation` | Wrong path — check `wp-path` argument | |
| 132 | | Timeout on large operations | Add `--ssh=user@host/path --allow-root` or increase SSH timeout | |
| 133 | |
| 134 | ### WP-CLI Aliases |
| 135 | |
| 136 | Define aliases in `~/.wp-cli/config.yml` for frequently-accessed sites: |
| 137 | |
| 138 | ```yaml |
| 139 | @client1: |
| 140 | ssh: user@client1.example.com/www/public |
| 141 | @client2: |
| 142 | ssh: user@client2.rocketcdn.me/www/client2/public |
| 143 | ``` |
| 144 | |
| 145 | Then: `wp @client1 post list` |
| 146 | |
| 147 | ### REST API Gotchas |
| 148 | |
| 149 | - Application passwords require HTTPS (won't work on HTTP) |
| 150 | - Some security plugins block REST API — check for 401/403 responses |
| 151 | - Caching plugins may serve stale REST responses — use `?_=${timestamp}` cache buster |
| 152 | - Custom post types need `show_in_rest: true` to appear in API |
| 153 | |
| 154 | --- |
| 155 | |
| 156 | ## Reference Files |
| 157 | |
| 158 | - `references/wp-cli-essentials.md` — SSH alias patterns, common flags, and troubleshooting |