2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WordPress setup

Last updated at Posted at 2019-04-01

wp-cli.phar を使って開発環境を構築する。

Install

# wp-cli
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

# Wordpressの準備
php ./wp-cli.phar core download --locale=ja # --version=4.0
php ./wp-cli.phar config create --dbhost=127.0.0.1 --dbname=sample2019db --dbuser=sample2019user --dbpass=sample2019pass --dbcharset=utf8mb4
php ./wp-cli.phar core install --url=http://127.0.0.1:8080 --title="sample 2019" --admin_name="admin" --admin_email="admin@example.com" --admin_password="passw0rd"

# プラグインのインストール&有効化
## https://blog-tip.com/wordpress/plugin/recommend/
php ./wp-cli.phar plugin activate akismet
php ./wp-cli.phar plugin delete hello
php ./wp-cli.phar plugin install cmb2 --activate

Theme & Post

# テーマの作成
# https://developer.wordpress.org/cli/commands/scaffold/_s/
php ./wp-cli.phar scaffold _s sample2019 --theme_name="sample 2019" --author="sample" --sassify --activate

# 既存テーマの削除
php ./wp-cli.phar theme delete twentynineteen
php ./wp-cli.phar theme delete twentyseventeen
php ./wp-cli.phar theme delete twentysixteen

# カスタム投稿の作成
# https://developer.wordpress.org/cli/commands/scaffold/post-type/
php ./wp-cli.phar scaffold post-type blog --label="ブログ" --theme="sample2019"
vi functions.php # require get_template_directory() . '/post-types/blog.php';

# タクソノミー(タグ)の作成
php ./wp-cli.phar scaffold taxonomy blog_tag --label="ブログのタグ" --post_types="blog" --theme="sample2019"
vi functions.php # require get_template_directory() . '/taxonomies/blog_tag.php';

# タクソノミー(カテゴリ)の作成
# 手動で「'hierarchical' => true」に設定
php ./wp-cli.phar scaffold taxonomy blog_category --label="ブログのカテゴリー" --post_types="blog" --theme="sample2019"
vi functions.php # require get_template_directory() . '/taxonomies/blog_category.php';

# 既存の固定ページの削除
php ./wp-cli.phar post delete $(php ./wp-cli.phar post list --post_type=page --field=ID --name="sample-page")
php ./wp-cli.phar post delete $(php ./wp-cli.phar post list --post_type=page --field=ID --name="privacy-policy" --post_status=draft)

# 固定ページ
php ./wp-cli.phar post create --post_type=page --post_status=publish --post_title="Company" --post_name="company"
php ./wp-cli.phar post create --post_type=page --post_status=publish --post_title="Message" --post_name="message" --post_parent=$(php ./wp-cli.phar  post list --post_type=page --field=ID --name="company")

Other

# 簡易Webサーバー(http://0.0.0.0:8080/wp-admin/)
php ./wp-cli.phar server --host=0.0.0.0 --port=8080

# 本体ばバージョン確認、アップデートの確認、アップデート
php ./wp-cli.phar core version
php ./wp-cli.phar core check-update
php ./wp-cli.phar core update

# プラグインの状態確認
php ./wp-cli.phar plugin status

# プラグインの検索
php ./wp-cli.phar plugin search "wordpress faq manager"

# プラグインのステータス確認 - 更新
php ./wp-cli.phar plugin status theme-my-login
php ./wp-cli.phar plugin update theme-my-login

# リライトリスト
php ./wp-cli.phar rewrite list --format=csv

# 画像サムネイルの再生成
php ./wp-cli.phar media regenerate --yes

# 画像のインポート
php ./wp-cli.phar media import /tmp/**\/*.jpg

# サンプルの投稿作成
php ./wp-cli.phar post generate --count=100 --post_type=blog

Links

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?