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:

發表回覆

你的電郵地址並不會被公開。 必要欄位標記為 *