Skip to main content

Install Plugins and Themes with WP-CLI

Learn how to install plugins and themes with WP-CLI and Terminus.


This section provides information on how to install WordPress plugins and themes with WP-CLI and Terminus.

Install WordPress Plugins

The WordPress plugin repository provides a list of free and paid plugins. The example below shows you how to install and activate the Contact Form 7 plugin.

  1. Install and activate the Contact Form 7 plugin:

    terminus wp $TERMINUS_SITE.dev -- plugin install contact-form-7 --activate
    • Go to the Site Dashboard to confirm that 78 files have changed and are ready to commit in the yellow box. You can use the Site Dashboard interface to review file changes and commit, or continue to use the command line as the example below.

    Pantheon Site Dashboard: Install CF7

  2. Review the file changes:

    terminus env:diffstat $TERMINUS_SITE.dev
  3. Commit your changes to the Dev environment:

    terminus env:commit $TERMINUS_SITE.dev --message="Install CF7"

    You can see the commit on the Dev environment if you refer back to the Site Dashboard: Pantheon Site Dashboard: Commit CF7

  4. Deploy the code to Test and pull content down from Live:

    terminus env:deploy $TERMINUS_SITE.test --sync-content  --updatedb --note="Deploy C7 plugin"
  5. Clear the site cache after deploying the code to Test:

    terminus env:clear-cache <site>.test
    Info:
    Note

    The --sync-content option will pull the database and files down from the Live environment. In a real-world scenario, your content editors most likely have added posts and files in the Live environment. These updates should be present on the Test environment with your deployed code for thorough testing. Run terminus env:deploy -h for more information on options for the this command.

  6. Activate the Contact Form 7 plugin on the Test environment by making a manual configuration change:

    terminus wp $TERMINUS_SITE.test -- plugin activate contact-form-7
  7. Verify that your Test environment and the new plugin are working correctly, and then deploy to Live:

    terminus env:deploy $TERMINUS_SITE.live --updatedb --note="Deploy after CF7 Install"
  8. Clear the site cache after deploying the code to Live:

    terminus env:clear-cache <site>.live
    Info:
    Note

    You don't need the --sync-content flag when going to the Live environment because that environment already has our canonical database.

  9. Activate the Contact Form 7 plugin on the Live environment by making a manual configuration change:

    terminus wp $TERMINUS_SITE.live -- plugin activate contact-form-7

    Manually applying configuration changes is a simple task for this example because you're only activating one plugin on each environment. However, complex configuration changes are best managed in code so you can pull fresh content from Live while bringing in the site settings from Dev.

Install WordPress Themes

The WordPress theme repository provides a list of free and paid themes you can install to customize your site. The example below uses the Shapely theme.

  1. Install and activate the Shapely theme:

    terminus wp $TERMINUS_SITE.dev -- theme install shapely --activate
  2. Run the terminus env:info command to retrieve the Dev environment's site URL:

    terminus env:info $TERMINUS_SITE.dev --field=domain
  3. Commit your changes to the Dev environment:

    terminus env:commit $TERMINUS_SITE.dev --message="Install shapely theme"
  4. Run the scaffold child-theme WP-CLI command to create a child theme (replace Tessa-child-theme and shapely to match your setup):

     terminus wp $TERMINUS_SITE.dev -- scaffold child-theme Tessa-child-theme --parent_theme=shapely
  5. Navigate to the WordPress Dashboard, select Appearance, and then select Themes to access the new theme.

    Pantheon Site Dashboard: Child Theme Installed in WordPress

    You can now edit your child theme. This allows your parent theme, in this example, Shapely, to receive updates without conflict or interference to the functionality of the site.

  6. Apply configuration changes, such as activating the child theme, verify that everything is correct on the Dev environment's site URL.

  7. Commit your changes to the Dev environment:

    terminus env:commit $TERMINUS_SITE.dev --message="Create Child of Shapely Theme"
  8. Deploy the themes to Test and pull content down from Live:

    terminus env:deploy $TERMINUS_SITE.test --sync-content --updatedb --note="Deploy Themes"
  9. Clear the site cache:

    terminus env:clear-cache <site>.live
  10. Apply configuration changes and verify that everything is correct on the Test environment's site URL.

  11. Deploy code to Live, then apply configuration changes:

    terminus env:deploy $TERMINUS_SITE.live --updatedb --note="Deploy Themes"
  12. Clear the site cache:

    terminus env:clear-cache <site>.live

More Resources