Home Kiến thức WebsiteWordPress Sử dụng WP-CLI quản lý theme WordPress

Sử dụng WP-CLI quản lý theme WordPress

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

Trước đây AZDIGI đã hướng dẫn dùng WP-CLI để quản lý plugin và user trên Wordpress. Bài viết này AZDIGI sẽ hướng dẫn các bạn sử dụng WP-CLI để quản lý theme.

Bài viết về WP-CLI bạn có thể xem lại:

Điều đâu tiên thì bạn cần phải truy cập vào Terminal

chrome oVWiV8wOqV

Tiếp theo bạn cần truy cập đến thư mục chứa website

Ở đây mình muốn quản lý theme website azdigiweb.com . Mình sẽ truy cập vào thư mục chưa mã nguồn azdigiweb.com bằng lệnh cd

AZDIGI Tutorial
[azdigi@azdigi.com ~]$ cd azdigiweb.com/
[azdigi@azdigi.com azdigiweb.com]$
    

Lưu ý:

  • Với domain chính (Primary Domain) thư mục chứa mã nguồn sẽ là public_html
  • Với domain addon: thư mục chứa mã nguồn sẽ nằm trong thư mục mang tên domain (nếu ban đầu bạn không thay đổi)

Sử dụng WP-CLI quản lý theme

Xem danh sách theme đang có trên website

AZDIGI Tutorial
[azdigi@azdigi.com azdigiweb.com]$ wp theme list
+-----------------+----------+--------+---------+
| name | status | update | version |
+-----------------+----------+--------+---------+
| oceanwp        | inactive | available | 1.7.4   |
| twentynineteen | inactive | none | 1.6 |
| twentyseventeen | inactive | none | 2.3 |
| twentytwenty | active | none | 1.4 |
+-----------------+----------+--------+---------+
    

Cài theme mới

Tìm một theme

Mình sẽ tìm theme có tên là Newsmag, mình nhập newsmag để tìm theme nào có tên này

AZDIGI Tutorial
[azdigi@azdigi.com azdigiweb.com]$ wp theme search newsmag
Success: Showing 3 of 3 themes.
+-----------------+-----------------+--------+
| name | slug | rating |
+-----------------+-----------------+--------+
| NewsMag | newsmag | 92 |
| The NewsMag | the-newsmag | 100 |
| MH NewsMagazine | mh-newsmagazine | 0 |
+-----------------+-----------------+--------+
    

Cài theme

Mình sẽ cài theme The NewsMag, bạn chỉ cần nhập lệnh install với tên slug là được.

AZDIGI Tutorial
[azdigi@azdigi.com azdigiweb.com]$ wp theme install the-newsmag
Installing The NewsMag (1.0.5)
Downloading installation package from https://downloads.wordpress.org/theme/the-newsmag.1.0.5.zip...
Unpacking the package...
Installing the theme...
Theme installed successfully.
Success: Installed 1 of 1 themes.
    

Kích hoạt theme

Để kích hoạt theme mình sẽ dùng lệnh sau

AZDIGI Tutorial
[azdigi@azdigi.com azdigiweb.com]$ wp theme activate the-newsmag
Success: Switched to 'The NewsMag' theme.
    

Update theme

Bạn có theme cần update, hãy nhập lệnh sau

AZDIGI Tutorial
[azdigi@azdigi.com azdigiweb.com]$ wp theme update oceanwp
Downloading update from https://downloads.wordpress.org/theme/oceanwp.1.8.3.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the theme...
Theme updated successfully.
+---------+-------------+-------------+---------+
| name    | old_version | new_version | status  |
+---------+-------------+-------------+---------+
| oceanwp | 1.7.4       | 1.8.3       | Updated |
+---------+-------------+-------------+---------+
Success: Updated 1 of 1 themes.
    

Để update toàn bộ theme bạn thêm option -all vào phía sau câu lệnh là được.

Delete theme

Ví dụ mình cần delete theme twentynineteen thì nhập lệnh như sau

AZDIGI Tutorial
[azdigi@azdigi.com azdigiweb.com]$ wp theme delete twentynineteen
Deleted 'twentynineteen' theme.
Success: Deleted 1 of 1 themes.
    

Vậy là AZDIGI đã hướng dẫn bạn cách sử dụng WP-CLI để quản trị theme. Ở bài viết sau AZDIGI sẽ hướng dẫn cài đặt WP-CLI lên VPS chưa hỗ trợ sẵn.

  • Hotline 247: 028 888 24768 (Ext 0)
  • Ticket/Email: Bạn dùng email đăng ký dịch vụ gửi trực tiếp về: support@azdigi.com
Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign