WordPress

WP-CLIコマンドでWordPressを自動化!WP-CLIの使い方

WordPress

  • download wordpress
    wp core download –locale=nl_NL
  • install wordpress
    wp core install –url=example.com –title=Example –admin_user=supervisor –admin_password=strongpassword –admin_email=info@example.com

    • セキュアな例
      wp core install –url=example.com –title=Example –admin_user=supervisor –admin_email=info@example.com –prompt=admin_password < admin_password.txt
  • update wordpress
    wp core update

    • 強制的にバージョンを下げる
      wp core update –version=3.1 –force
  • show version
    wp core version –extra

post

  • update
    wp post update 80 –post_status=Publish –post_content=”foo”

media

  • from path
    wp media import ~/Pictures/**\/*.jpg
  • from web
    wp media import https://s.w.org/style/images/wp-header-logo.png --title='The WordPress logo' --alt="Semantic personal publishing"

SQL / DB

  • run sql
    wp db query ‘SELECT * FROM wp_options WHERE option_name=”home”‘ –skip-column-names
  • show table
    wp db tables –scope=blog –url=sub.example.com

scaffold

  • child-theme (子テーマ)
    wp scaffold child-theme sample-theme –parent_theme=twentysixteen

wp scaffold

References:
https://developer.wordpress.org/cli/commands/