コマンドラインからWordPressを操作するwp-cliネタ、今回は恐らく皆さん一番知りたいネタではないでしょうか?テーマの検索とインストール、有効化について取り上げます。
■ テーマ一覧を確認する
wp theme list でテーマのリストを表示します。列の見方は前回のプラグインと一緒ですね。
$ wp theme list --path=/home/vhosts/$(uname -n)/public_html/ +----------------+----------+--------+---------+ | name | status | update | version | +----------------+----------+--------+---------+ | twentyfifteen | active | none | 1.0 | | twentyfourteen | inactive | none | 1.3 | | twentythirteen | inactive | none | 1.4 | +----------------+----------+--------+---------+
■ テーマを検索する
春をイメージするテーマを検索してみましょう。今回は2件出てきました。
$ wp theme search spring --path=/home/vhosts/$(uname -n)/public_html/ Success: Showing 2 of 2 themes. +----------------+----------------+--------+ | name | slug | rating | +----------------+----------------+--------+ | Tender Spring | tender-spring | 100 | | SpringFestival | springfestival | 60 | +----------------+----------------+--------+
■ テーマをインストールして即アクティベートする
先ほど検索して出てきたテーマのうち、Tender Springをインストールします。引数に –activate をつけることで、インストール完了後即有効化されます。
$ wp theme install tender-spring --activate --path=/home/vhosts/$(uname -n)/public_html/ Installing Tender Spring (1.0.11) https://wordpress.org/themes/download/tender-spring.1.0.11.zip からインストールパッケージをダウンロードしています… パッケージを展開しています… テーマをインストールしています… テーマのインストールが完了しました。 Activating 'tender-spring'... Success: Switched to 'Tender Spring' theme.
テーマの一覧を見てみましょう。tender-springが有効化されていることがわかります。
$ wp theme list --path=/home/vhosts/$(uname -n)/public_html/ +----------------+----------+--------+---------+ | name | status | update | version | +----------------+----------+--------+---------+ | tender-spring | active | none | 1.0.11 | | twentyfifteen | inactive | none | 1.0 | | twentyfourteen | inactive | none | 1.3 | | twentythirteen | inactive | none | 1.4 | +----------------+----------+--------+---------+
それにしても、こんなゆるふわテーマに般若心経はちょっと・・・ (;´д`)
なお、テーマの削除は「wp theme delete テーマ名」で行えますが、現在アクティブなテーマを削除しようとするとエラーになります。
