Home Website TutorialsWordPress How to use WP-CLI to manage WordPress themes

How to use WP-CLI to manage WordPress themes

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

Previously, AZDIGI guided using WP-CLI to manage plugins and users on WordPress. In this article, AZDIGI will show you to use WP-CLI to manage themes.

You can refer to the articles about WP-CLI below:

First, you need to access the Terminal.

chrome oVWiV8wOqV

Next, you access the directory containing the website.

For example, I want to manage the theme of the website azdigiweb.com. I will access the directory containing the source code azdigiweb.com with the cd command.

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

Note:

  • Primary Domain: the directory containing the source code will be public_html
  • Addon Domain: the folder containing the source code will be in the folder named domain (if you didn’t change it initially)

Use WP-CLI to manage the theme

See the list of installed themes on the 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 |
+-----------------+----------+--------+---------+
    

Install a new theme

Find a theme

I will look for a theme called Newsmag, I type newsmag to find this theme

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 |
+-----------------+-----------------+--------+
    

Install theme

I will install The NewsMag theme, you just need to enter the install command with the name slug.

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.
    

Active the theme

To activate the theme, I will use the following command:

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

Update theme

If you want to update the theme, enter the following command:

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.
    

To update the entire theme, add the -all option after the command.

Delete theme

For example, if I want to delete the twentynineteen theme, enter the following command:

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

So AZDIGI has guided you through how to use WP-CLI for theme administration. In the next article, AZDIGI will guide you to install WP-CLI on an unsupported VPS.

  • Hotline 247: 028 888 24768 (Ext 0)
  • Ticket/Email: You can use your email to register for the service and send it directly to: 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