Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Adv WP CLI

Tom J Nowell
September 23, 2014

Adv WP CLI

Advanced WP CLI talk for WP Leeds dev night

Tom J Nowell

September 23, 2014
Tweet

More Decks by Tom J Nowell

Other Decks in Technology

Transcript

  1. Advanced
    WP CLI
    A WPLeeds talk by Tom J Nowell

    View full-size slide

  2. I’m Tom J Nowell
    Code For The People

    View full-size slide

  3. I’ll Cover
    ● What is WP CLI
    ● Some WP CLI Commands & Usage
    ● Demo

    View full-size slide

  4. WP CLI
    WordPress, Command Line Interface
    A tool for terminal users

    View full-size slide

  5. What is The Terminal?

    View full-size slide

  6. Once installed, open your WordPress folder on
    the terminal
    GIF by Chris Coyier of CSS Tricks

    View full-size slide

  7. Some of the Things WP CLI Can Do
    ● Create Posts
    ● Create Users
    ● Download plugins and themes
    ● Database Queries
    ● Installing WordPress

    View full-size slide

  8. E.g. Adding an author to a site:
    ❯ wp user create bob [email protected]
    --role=author

    View full-size slide

  9. Listing activated plugins
    ❯ wp plugin list --status=active --
    format=csv --fields=name

    View full-size slide

  10. Doing a Search replace
    ❯ wp search-replace oldsite.com
    newsite.com

    View full-size slide

  11. List blogs, and their URLs in a multisite
    ❯ blogs=$(wp site list --fields="site_id,
    blog_id,url" --format="csv")
    for entry in $blogs
    do
    site_id=$(echo $entry |cut -d ',' -f1 )
    blog_id=$(echo $entry |cut -d ',' -f2 )
    blog_url=$(echo $entry |cut -d ',' -f3 )
    echo "$blog_id: $blog_url in $site_id"
    done

    View full-size slide

  12. A demonstration

    View full-size slide

  13. Questions?
    Tom J Nowell
    @tarendai
    tomjn.com

    View full-size slide