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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

  5. What is The Terminal?

    View Slide

  6. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  12. 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 Slide

  13. A demonstration

    View Slide

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

    View Slide