IT, 筆記

Build WordPress theme from scratch (1)

Start the brand-new WordPress service with Docker:

version: "3.7"

services:
  db:
    # restart: always
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: wordpressdb
      MYSQL_USER: tester
      MYSQL_PASSWORD: tester1234
      MYSQL_RANDOM_ROOT_PASSWORD: "1"
    volumes:
      - mysql_data:/var/lib/mysql

  wordpress:
    image: wordpress:latest
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: tester
      WORDPRESS_DB_PASSWORD: tester1234
      WORDPRESS_DB_NAME: wordpressdb
    volumes:
      - wordpress_data:/var/www/html/wp-content

volumes:
  wordpress_data:
  mysql_data:

In order to make some dummy post for theme testing, I try this plugin: FakerPress

Generate about 10 post and check the default theme.

Since I start the docker in Windows WSL2, I can attach VSC to the WordPress container directly:

After attach VSC successfully, open the folder: /var/www/html/wp-content/themes/

Let's start a new theme - Create a folder called mytesttheme

Let's See some reference:

I follow the "How to Create a Minimal WordPress Theme". I create the files and the the file structure like this:

Theme preview in WordPress looks like this:

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *