🥹Installing WP-CLI in Windows (ok)
https://make.wordpress.org/cli/handbook/guides/installing/
Sử dụng: https://wp-cli.org/
Đây cách này hay dùng (nó tạo ra 1 file upload duy nhất)

Ta thấy nó tạo duy nhất 1 link

Kể cả shop cũng vậy

Trong back-end cũng hiển thị 1 ảnh chỗ thumbnail

Rồi ta tắt đi và thực hiện lại nó lại hoạt động

Đôi khi nó hoạt động như điên ta chỉ cần tắt trong functions.php nó hoạt động không như lúc trước ta cần phải vào media.php cần chú ý

Ta thử up 1 ảnh xem sao nó đúng là chỉ tạo 1 ảnh


Hiện tại không hiểu sao nó chỉ chạy cách 2

Cách 1: dùng 1 lệnh composer global require wp-cli/wp-cli
composer global require wp-cli/wp-cli
If you're seeing "zsh: command not found: wp" when trying to use WP-CLI in your site shell, it means that the WP-CLI tool isn't installed or properly configured on your system, and you need to install it before you can use its commands within your site shell. How to Fix:
Install WP-CLI:
Using Composer:
Open your terminal and navigate to your WordPress root directory.
Run the command:
composer global require wp-cli/wp-cli
Manually (on Linux/macOS):
Download the latest WP-CLI package from the official website.
Extract the archive and place the
wp
executable file in a directory within your system path (e.g.,/usr/local/bin
).
Things to Check:
Path Variable:
Ensure that the directory containing the
wp
executable is added to your system'sPATH
environment variable.You can check this by running
echo $PATH
in your terminal.
Site Shell Access:
Verify that your site shell is properly configured to access the correct WordPress directory on your server where WP-CLI should be available.
Permissions:
Make sure you have the necessary permissions to execute the
wp
command.
Troubleshooting Steps:
Check Installation:
Try running
wp --version
in your terminal. If it returns information about the WP-CLI version, it's installed correctly.
Re-source Environment:
If you recently installed WP-CLI, try re-sourcing your shell configuration file (e.g.,
.bash_profile
or.zshrc
) to update your environment variables.
Specific Environment Issues:
Local Development: If you're using a local development environment like Local by Flywheel, check their documentation for specific instructions on installing and using WP-CLI.
Cách 2: Cài bằng cách tải file về.
C:\wp-cli\wp.bat
@ECHO OFF
php "C:/wp-cli/wp-cli.phar" %*

C:\wp-cli
C:\xampp\php
wp --info


Ví dụ:

https://developer.wordpress.org/cli/commands/plugin/install/
wp plugin install bbpress --activate

Cài đặt trên git
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
wp --info

https://developer.wordpress.org/cli/commands/post/create/
Config
C:\xampp\htdocs\example\wp-cli.yml
# Global parameter defaults
path: C:/xampp/htdocs/example
url: http://localhost/example
user: admin
color: false
disabled_commands:
- db drop
- plugin install
require:
- path-to/command.php
# Subcommand defaults (e.g. `wp config create`)
config create:
dbuser: root
dbpass:
extra-php: |
define( 'WP_DEBUG', true );
define( 'WP_POST_REVISIONS', 50 );
# Aliases to other WordPress installs (e.g. `wp @staging rewrite flush`)
# An alias can include 'user', 'url', 'path', 'ssh', or 'http'
@staging:
ssh: wpcli@staging.wp-cli.org
user: wpcli
path: /srv/www/staging.wp-cli.org
@production:
ssh: wpcli@wp-cli.org:2222
user: wpcli
path: /srv/www/wp-cli.org
# Aliases can reference other aliases to create alias groups
# Alias groups can be nested
@both:
- @staging
- @production
# '_' is a special value denoting configuration options for this wp-cli.yml
_:
# Merge subcommand defaults from the upstream config.yml, instead of overriding
merge: true
# Inherit configuration from an arbitrary YAML file
inherit: prod.yml


wp post create --post_type=post --post_author='wordpress' --post_title='A future post' --post_status=future --post_date='2020-12-01 07:00:00'

Quick Start
https://make.wordpress.org/cli/handbook/guides/quick-start/
wp core download --path=wpclidemo.dev
Last updated
Was this helpful?