Skip to content

Instantly share code, notes, and snippets.

@MikeNGarrett
Last active October 19, 2020 12:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeNGarrett/b24b4c331c6e195458249d6b45cbd354 to your computer and use it in GitHub Desktop.
Save MikeNGarrett/b24b4c331c6e195458249d6b45cbd354 to your computer and use it in GitHub Desktop.
Quick tips for Pantheon's implementation of WordPress CLI.
# Pantheon's Terminus is awesome, but it can be frustrating when you're first getting used to the syntax.
# Some quick tips follow.
#
# The following applies for Terminus v1.4+
#
# When specifying WP CLI commands to run, separate the terminus commands from the wp cli commands with 2 dashes:
terminus remote:wp sitename.env -- command-name --flag=value "wp-content/path/to/file-name.ext"
# It also helps to wrap paths in double quotes.
# Paths never begin with a /.
# Assume you're running the remote commands in the web root.
# CLI command flags are specified after the double dash and command name.
# For example:
terminus remote:wp sitename.env -- user list --field=ID
# Another more complex and commonly-used example:
terminus remote:wp sitename.env -- search-replace "://dev-sitename." "://live-sitename." --skip-columns=guid --all-tables --dry-run
# ^ It's important to wrap the search term and replacement in double quotes.
# Here's how I import WXR xml files.
# First, add the files to your theme or somewhere you can get to them.
# Note, the media library doesn't support xml by default.
# Then run your media import first:
terminus remote:wp sitename.env -- import --authors=create "wp-content/themes/theme-name/import-xml/media-date.xml"
# Next, run your posts import. This allows featured images to be associated with your imported content.
terminus remote:wp sitename.env -- import --authors=create "wp-content/themes/theme-name/import-xml/posts-date.xml"
# Remember to remove these files when you're done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment