LoginSignup
1
1

More than 5 years have passed since last update.

wordmoveを使ってwordpressのソースコードを持ってきてテーマの編集を行う。

Posted at

レンタルサーバーの自動インストールやらサーバーで直接wordpressを置いたりした後に「この部分の表示を調整したい」時が多々ある。wordpressの管理画面上からテーマの表示調整は可能だが、テーマの更新があった時に調整した分が消えてしまう。「そうならないように子テーマを作りましょう」とは言われるのは解ってはいるのだが何だか面倒に思えた。

だけど実際に手順をまとめて見たら1コマンド打つだけなのでとても簡単でした。手順を忘れるためにも書いておく。

ちなみに公開環境からローカル環境に持って来て表示確認するのを目的としているが、本番環境で子テーマを作るコマンド1つ打って子テーマの編集を直接やるのもありかもしれない。Windowsだとローカル環境の構築が面倒だからそれやる人もいるかもだけど当方Mac、Windowsユーザーはそこらへん読み替えて実行してください。vccwとかがいいのかな。Macならvccwなくても開発可能。

gem i wordmove
wordmove init
vi Movefile
local:
  vhost: "http://localhost:8080"
  wordpress_path: "/current/path/wp" # use an absolute path here

  database:
    name: "wordpress"
    user: "root"
    password: ""
    host: "127.0.0.1"

production:
  vhost: "https://example.com"
  wordpress_path: "/home/example/example.com/public_html/wp" # use an absolute path here

  database:
    name: "wp_db"
    user: "wp_user"
    password: "pass"
    host: "wp_host"
    # port: "3308" # Use just in case you have exotic server config
    # mysqldump_options: "--max_allowed_packet=1G" # Only available if using SSH

  exclude:
    - ".git/"
    - ".gitignore"
    - ".sass-cache/"
    - "node_modules/"
    - "bin/"
    - "tmp/*"
    - "Gemfile*"
    - "Movefile"
    - "wp-config.php"
    - "wp-content/*.sql"

  # paths: # you can customize wordpress internal paths
  #   wp_content: "wp-content"
  #   uploads: "wp-content/uploads"
  #   plugins: "wp-content/plugins"
  #   mu_plugins: "wp-content/mu-plugins"
  #   themes: "wp-content/themes"
  #   languages: "wp-content/languages"

  ssh:
    host: "example.com"
    user: "example"
    #password: "password" # password is optional, will use public keys if available.
    port: 22 # Port is optional
    rsync_options: "--verbose" # Additional rsync options, optional
    #gateway: # Gateway is optional
    #  host: "host"
    #  user: "user"
    #  password: "password" # password is optional, will use public keys if available.

  # ftp:
  #   user: "user"
  #   password: "password"
  #   host: "host"
  #   passive: true
  #   scheme: "ftps" # default "ftp"

# staging: # multiple environments can be specified
#   [...]
mysql -uroot -e 'create database wp_db;'
wordmove pull -e production --all
wp core config --dbname=wp_db --dbuser=root --dbpass='' --dbhost='127.0.0.1' --locale=ja_JP
wp server

ローカル環境に持ってくるまでの手順。これで http://localhost:8080 でアクセスが可能になる。子テーマの作成コマンドは以下 first のテーマを親として first-child の子テーマを作成するコマンド。

wp scaffold child-theme first-child --parent_theme=first

wp-content/themes/first-child/ が作成されるので管理画面からテーマ有効にしたり編集したいファイルを持って来て変更したりして上書きしましょう。

以下がデプロイ

wordmove push -e production --all
1
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
1
1