Skip to content

Instantly share code, notes, and snippets.

@jerivas
Last active July 31, 2018 23:58
Show Gist options
  • Save jerivas/edcff83052819f484b2eb1db54fd7d4c to your computer and use it in GitHub Desktop.
Save jerivas/edcff83052819f484b2eb1db54fd7d4c to your computer and use it in GitHub Desktop.
WordPress developer workflow

rsync_excludes.txt

.git
node_modules
wp-config.php

Getting started off a production site

On the server:

cd path/to/project
wp db export # Requires wp-cli on the server
# A new file will be created, like example_com-2018-07-31-f72f641.sql

On your local machine:

cd path/to/target
rsync -az --exclude-from ../rsync-excludes.txt --info progress2 user@host:path/to/project/ .
wp config create # Requires wp-cli in your local machine
# Now you will have a brand new wp_config.php file, edit it with your DB credentials
# Now, import the dump we created on the server
wp db import name_of_backup.sql
# Also, let's rename everything to work on the local domain
wp search-replace 'http://example.com' 'http://example.test' --skip-columns=guid

# Now, let's link a theme cloned from a repo
# Start on a differente folder, like ~/wordpress/themes
git clone <theme URL>
cd /path/to/site
rm -rf wp-content/<selected theme>
ln -s path/to/repo wp-conten/<selected theme>
# Now your version-controlled theme will be used by the site
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment