WordPress has a user-friendly graphical interface that makes site management simple.
But did you know there’s another way to run your website?
Meet WP-CLI, the WordPress Command Line Interface. It does everything WP Admin can, plus more.
You can use it to interact with your site through the command line in a terminal, which can actually save you a lot of time — whether you’re managing content, plugins, themes, users, or anything else.
In this guide, we’ll cover what WP-CLI is and share some useful commands to help you get up to speed.
Whether your site’s hosted by WordPress.com or another provider, WP-CLI could be the skill upgrade you’re looking for to make managing sites more efficient and flexible.
is the official command-line interface for WordPress. It’s been built to help developers manage their sites more quickly and flexibly.
Instead of managing a site through the graphical WP Admin interface in a browser, WP-CLI lets you run powerful commands from your choice of terminal software.
For example, with commands, you can:
You can even create a new WordPress installation, switch to a different version of WordPress core, and search for and replace strings in the database — things you can’t do from WP Admin.
WP-CLI is an open-source project, just like WordPress itself.
It was originally created by
, and former Automattician
, and is now maintained by
r with contributions from developers all over the world.
To ensure compatibility with the latest versions of WordPress,
. Updates are usually rolled out every three to four months and include new commands and improved performance.
At its core, WP-CLI aims to make WordPress more developer-friendly.
Once you get comfortable with it, you can manage one or many sites more efficiently — and even automate tasks you’d never be able to in WP Admin.
Some web hosts include WP-CLI by default — and WordPress.com is one of them.
To use WP-CLI on
, your site needs to be on the
.
First, make sure you have
to the server where WordPress is installed.
To check if WP-CLI is installed, try running a version check by entering the following command:
If WP-CLI is installed, you’ll see something like:
If not, you’ll get a message such as:
If WP-CLI isn’t installed yet,
.
The main reasons to use WP-CLI over WP Admin are the efficiency and access advantages.
It lets you:
Sure, you need to learn a new way of working with WordPress to get the full benefits of WP-CLI.
However, it doesn’t take long to get familiar with this approach, and once you are, you’ll be working much more efficiently.
If your site is hosted on the
, you can use WP-CLI plus get access to a few WordPress.com-only commands, some of which we cover later in this guide.
The best part? As WP-CLI was built for developers, you get a lot of freedom in how you use it.
Let’s go over some examples of common commands and why you might want to use them.
Before we get to the examples, it’s worth taking a look at the format of the commands.
WP-CLI commands generally follow this structure:
Every command starts with wp, which tells the shell you’re running a WP-CLI command. wp is then followed by a command and often a subcommand.
Examples include plugin and list — the command for listing all the plugins installed on the site:
The commands can also include arguments, such as:
[IMG alt="WP-CLI-Examples-wp-plugin-update
"]
This command updates the hello-dolly plugin (if an update is available).
Flags can also be added to commands. They start with — and either toggle options or pass a value to the command.
For example, when adding the –status=active flag to the wp plugin list command, it will only list the active plugins on the site:
You can also chain commands together using &&, such as:
This command installs and activates the Contact Form 7 and Akismet plugins, along with the Twenty Twenty-Five theme.
You can add –help to any command to view its subcommands, flags, and other information in WP-CLI.
For example:
As we go through the examples, you’ll get a better idea of how WP-CLI commands are structured.
You can use WP-CLI through terminal software, including the free
and
apps.
You can also use loops and Bash scripts with WP-CLI to build more advanced, automated workflows — performing bulk updates, managing multiple sites, and streamlining complex WordPress maintenance tasks with a single command.
wp plugin is a handy command for interacting with plugins on a site via WP-CLI.
It lets you install, update, and delete plugins using commands rather than navigating multiple steps in WP Admin — and saves you a lot of time.
For example, if you often set up new sites and have a list of plugins from the WordPress.org Plugin Directory that you always install, you can achieve this with a single time-saving command.
You can also easily update plugins you’ve installed from the WordPress.org Plugin Directory from the command line. Switching to different versions of a plugin, including older versions, from the command line is straightforward, too.
Finally, you can install and update plugins from other sources using WP-CLI. This won’t work for all plugins, as you’ll need to enter their URL, and WP-CLI must be able to access the ZIP file. However, if the files are accessible, then you should be able to install them.
Let’s have a look at some of the most useful wp plugin commands.
Use the following command to see which plugins are installed on the site:
This command not only lists all the plugins installed on the site, but also displays their status, version number, and whether an update is available.
You can add flags to the wp plugin list command to modify what it returns, such as:
This command will only list the plugins that have an update available.
You can see all the flags available for a specific command by adding the –help flag to it.
For example:
If the site you’re working on has plugins installed that are hosted in the WordPress.org Plugin Directory and have an update available, they can be updated using the following command:
You can exclude plugins from the update by using the –exclude flag:
Excluding a plugin can be useful if you haven’t tested the latest version of a plugin and don’t want to install it.
As you can see below, all plugins have been updated, except for Edit Flow, as requested.
WP-CLI can be used to install plugins hosted in the WordPress.org Plugin Directory.
You can also install plugins by entering the path to a local zip file or a URL to a remote zip file.
To install one or more plugins from the WordPress.org Plugin Directory, use the following command appended by the name of the plugin(s):
For example, to install BuddyPress and Contact Form 7, enter:
When entering the name of the plugin, you must use the plugin’s slug in the WordPress.org Plugin Directory.
To find the plugin’s slug, visit the plugin page in the WordPress.org Plugin Directory and locate the slug in the URL:
If you’d like the plugins also to be activated after installation, add the –activate flag to the end of the command:
If a plugin update causes errors, you can roll it back to a previous version using the command:
This reinstalls the specified version of the plugin, letting you revert safely to a stable version.
You can find more information about installing plugins, including instructions on how to install plugins not listed in the WordPress Plugin Directory, on the
page of the WordPress Developer Resources site.
You can also deactivate one or more plugins from the command line.
This can be especially useful if the site has become unresponsive due to a plugin-related issue that’s preventing you from accessing WP Admin and deactivating the plugin via the browser.
Some of your options for deactivating plugins include deactivating a specific plugin by name, using the –all flag to deactivate all plugins, and deactivating all plugins except for specific ones.
For example, to deactivate a specific plugin, use the following command:
To deactivate all plugins, use this command:
To deactivate all plugins except for specific plugins, use the following command:
You can view the other options in the
, and for more plugin-related commands, view the
.
You can also work with posts and pages using WP-CLI.
First up, you can quickly get a list of all posts on a site using the following command:
To see a list of pages, add this flag to the command:
You can see a list of posts and pages using this command:
The
of the WordPress Developer Handbook provides more information about retrieving lists of posts.
As you might expect, the wp post create command lets you create posts and pages with WP-CLI.
If you regularly set up new sites that include the same set of pages, such as about, contact, and services pages, you can quickly create those pages using a single command.
For example, the following command will create a post with the title “Created Using WP-CLI.”
To create more than one post, you can chain multiple commands together using &&:
By default, new posts are saved as drafts.
However, you can change this by using the –post_status= flag and adding a command, such as publish, draft, or pending.
For example, to create a new post with the title “Created Using WP-CLI” with its status set to published, use the following command:
You can also add content to the post, assign an author, set the publish date, and more by using the appropriate flags.
More information about the
command can be found in the WP-CLI documentation.
If you’re starting a new site and want to populate it with placeholder content, then the wp post generate command will come in handy.
This command is deal for creating test content for a new site design or populating a site with thousands of posts to test performance.
It creates multiple posts with a single command.
Like with other commands, you can add flags to the wp post generate command.
Other flags that can be used with wp post generate include: –post_type=, –post_status=, –-post_author=, and –post_date=.
For example:
The above command will create 10 draft pages by the author with ID 1 with the creation date and time set to January 15, 2025, 12:15 pm.
You can find out more about the
command in the WordPress Developer Handbook.
You can also update or change existing posts using WP-CLI.
The wp post update command flags let you update the title, body, excerpt, publish date, status, and author.
As you can update multiple posts at once, this command is useful for changing the status for multiple posts from published to draft or assigning a different user as the author.
When updating multiple posts with a single command, you must refer to the posts using their ID. To see the IDs for each post, use this command:
Once you have the IDs for each post you want to update, you can refer to them in the command, separated by a space.
Here’s an example of a wp post update command that updates multiple posts:
This command changes the author of the posts with IDs 1, 125, and 283 to the user with ID 2.
(To view the list of users and their IDs, use the wp user list command.)
To build upon that command, if you wanted to change the author of all posts by a specific author to a different author, you could use this command:
This command retrieves a list of all posts authored by the author with author ID 52288503, then updates or changes them so that the author is now the one with ID 52288502.
You could use the same approach to change the status of all published posts to draft by using this command:
You can see what else is possible with this command on the
of the WP-CLI documentation.
Deleting posts is another task that you can carry out with WP-CLI.
Again, the post IDs are used when specifying which post(s) to delete:
To delete multiple posts, separate the IDs with a space:
By default, posts are moved to the trash. However, you can use the –force flag to skip the trash folder and delete the post:
If you want to delete all pages, you can use the following command:
This command deletes all posts by a specific user:
The wp theme commands also let you carry out several theme-related tasks on a site.
To quickly view a list of all themes on the site, along with their status, whether an update is available, and the version number, enter the following command:
You can activate a specific installed theme using the following command:
Like plugins, you can install themes from the command line.
If you want to install a theme from the
, you’ll need to use its slug.
Like plugins, the slug is in the URL of the theme’s page in the WordPress Theme Directory.
For example, if you want to install the
theme, you need to enter its name as twentytwentyfour based on its slug.
If you want to activate the theme after installing it, add the –activate flag:
A single command can update all of the themes that have an available update:
You can also exclude themes from the update by using the –exclude flag:
Besides, the wp comment command gives you a quick way to view and delete spam comments on the site, as well as interact with comments in other ways.
You can see the comments on a site by using the following command:
However, this doesn’t always include spam comments in the list. To see spam comments, use this command:
Then, to delete the spam comments, use the wp comment delete command with the wp comment list command:
Here are some additional commands that can help you manage and troubleshoot WordPress sites:
You can manage a WordPress site’s cache using the wp cache command.
wp cache flush is useful as it can fix issues where site changes, such as post edits, theme updates, or settings changes, aren’t displayed.
WordPress automatically regenerates the cache the next time the site is loaded, ensuring the most up-to-date version is shown.
The WordPress Developer Resources has more information on the
and
commands.
You can also perform database operations with WP-CLI.
The wp db export command creates a backup of your WordPress database as an .sql file — something that’s worth doing before making major site changes. You can also use WP-CLI to export specific tables, exclude tables, or import a database file.
More information about the
and
commands can be found in the WordPress Developer Resources.
The wp rewrite flush command refreshes WordPress’s permalink structure and rewrite rules. It can fix 404 errors that occur after adding custom post types or changing permalink settings.
You can find out more about this command in the
of the WordPress Developer Resources.
The wp search-replace command lets you search for a string in your WordPress database and replace it with another.
It’s especially useful for updating URLs after a site migration or correcting text across posts, pages, and settings. Using the –dry-run flag lets you preview changes before applying them.
An example of this command would be:
(add grey box/background
This command previews all instances of energise that would be replaced with energize. If you’re happy with the output, you can run the same command without the –dry-run flag to apply the changes.
The above are just a few examples of how you can use WP-CLI to interact with your WordPress site outside of the WP Admin interface.
Hopefully, this has inspired you to start interacting with WordPress from the command line.
For more information on using WP-CLI, check out
in the documentation.
WP-CLI is included with the WordPress.com
.
Some core commands aren’t supported, but there are a few others that are exclusive to
sites.
To see exactly what’s available on the WordPress.com Business and Commerce hosting plans, enter the following command:
Doing so will reveal all of the WP-CLI commands available to your site based on your plan.
is a WordPress.com-specific command that includes several useful subcommands for managing your site.
One such command is wp wpcomsh diag.
This command runs site diagnostics tests and outputs the results, including the status of plugins, accounts with administrator access, details of active WordPress.com hosting plans and services, critical PHP errors, and more.
It’s a quick and easy way to get a detailed overview of a site’s status.
If there are errors on the site, the following command disables all plugins and enables them one by one to check if a specific plugin is causing the issue:
You can also
and
via WP-CLI.
For more WordPress.com-specific WP-CLI commands, check out the complete list in the
.
As you can see, being able to use WP-CLI is another reason why WordPress.com isn’t just for hosting simple blogs; it’s a developer-friendly platform with advanced tooling.
There’s a lot more you can do with WP-CLI, from checking out the full list of commands to
.
You can also create Bash scripts that contain multiple WP-CLI commands. Then, instead of running each command individually, you can run the entire script at once.
For example, you could create a Bash script called update.sh that includes WP-CLI commands to update all plugins and themes:
You can then run the script with ./update.sh. The script’s contents will execute, which in this case, will update the themes and plugins on the site.
That’s just a sample of what’s possible with WP-CLI. To learn more,
.
WP-CLI is a great tool for developers and site owners who want more control over their site while spending less time clicking around in WP Admin.
The biggest hurdle to getting started is usually a mental one.
In most cases, opening your terminal software and logging in for the first time takes only a few minutes. After that, you’ll have a faster, more efficient way to manage your site.
Beyond its speed and efficiency, WP-CLI offers other practical advantages.
You can deactivate plugins and themes, toggle settings when WP Admin is inaccessible, and even generate dummy content with a single command.
To try it out, sign up for the
.
Another useful tool to explore is
, a free open-source desktop app from WordPress.com for building local WordPress sites. In addition to letting you spin up sites in seconds, sync with WordPress.com or Pressable, and import any WordPress site to work on locally, it
.
But did you know there’s another way to run your website?
Meet WP-CLI, the WordPress Command Line Interface. It does everything WP Admin can, plus more.
You can use it to interact with your site through the command line in a terminal, which can actually save you a lot of time — whether you’re managing content, plugins, themes, users, or anything else.
In this guide, we’ll cover what WP-CLI is and share some useful commands to help you get up to speed.
Whether your site’s hosted by WordPress.com or another provider, WP-CLI could be the skill upgrade you’re looking for to make managing sites more efficient and flexible.
What is WP-CLI?
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Instead of managing a site through the graphical WP Admin interface in a browser, WP-CLI lets you run powerful commands from your choice of terminal software.
For example, with commands, you can:
- Install a list of plugins on a site
- Assign multiple posts to a different user
- Create new users
- Delete all spam comments.
You can even create a new WordPress installation, switch to a different version of WordPress core, and search for and replace strings in the database — things you can’t do from WP Admin.
The story behind WP-CLI
WP-CLI is an open-source project, just like WordPress itself.
It was originally created by
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
To ensure compatibility with the latest versions of WordPress,
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
At its core, WP-CLI aims to make WordPress more developer-friendly.
Once you get comfortable with it, you can manage one or many sites more efficiently — and even automate tasks you’d never be able to in WP Admin.
How to install WP-CLI
Some web hosts include WP-CLI by default — and WordPress.com is one of them.
To use WP-CLI on
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
First, make sure you have
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
To check if WP-CLI is installed, try running a version check by entering the following command:
wp cli versionIf WP-CLI is installed, you’ll see something like:
WP-CLI 2.12.0If not, you’ll get a message such as:
command not found: wpIf WP-CLI isn’t installed yet,
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Why use WP-CLI?
The main reasons to use WP-CLI over WP Admin are the efficiency and access advantages.
It lets you:
- Execute commands in seconds instead of clicking through multiple screens in WP Admin, saving time when setting up new sites or managing existing ones.
- Keep working even if a problem prevents you from accessing WP Admin — for example, a plugin conflict. In those cases, WP-CLI lets you disable plugins, create user accounts, and update WordPress core, all without using WP Admin.
- Perform tasks that WP Admin doesn’t allow without installing extra plugins, such as interacting with the database or running bulk actions like installing and activating multiple themes or plugins with one command, generating dummy content, rolling back WordPress core or plugin versions, and managing multiple sites on the same server from a single command.
- Combine WP-CLI commands into chains or scripts to automate entire workflows — for example, setting up a new site, configuring settings, creating user accounts, installing plugins, and generating dummy content, all from one script.
Sure, you need to learn a new way of working with WordPress to get the full benefits of WP-CLI.
However, it doesn’t take long to get familiar with this approach, and once you are, you’ll be working much more efficiently.
If your site is hosted on the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
The best part? As WP-CLI was built for developers, you get a lot of freedom in how you use it.
Examples of common WP-CLI commands and what you can do with them
Let’s go over some examples of common commands and why you might want to use them.
Before we get to the examples, it’s worth taking a look at the format of the commands.
WP-CLI commands generally follow this structure:
wp <command> <subcommand> [arguments] [--flags] [--flag=value]Every command starts with wp, which tells the shell you’re running a WP-CLI command. wp is then followed by a command and often a subcommand.
Examples include plugin and list — the command for listing all the plugins installed on the site:
wp plugin list
The commands can also include arguments, such as:
wp plugin update hello-dolly[IMG alt="WP-CLI-Examples-wp-plugin-update
"]
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
This command updates the hello-dolly plugin (if an update is available).
Flags can also be added to commands. They start with — and either toggle options or pass a value to the command.
For example, when adding the –status=active flag to the wp plugin list command, it will only list the active plugins on the site:
wp plugin list --status=active
You can also chain commands together using &&, such as:
wp plugin install contact-form-7 --activate && wp plugin install akismet --activate && wp theme install twentytwentyfive --activateThis command installs and activates the Contact Form 7 and Akismet plugins, along with the Twenty Twenty-Five theme.
You can add –help to any command to view its subcommands, flags, and other information in WP-CLI.
For example:
Kod:
wp plugin --help
wp plugin list --help
As we go through the examples, you’ll get a better idea of how WP-CLI commands are structured.
You can use WP-CLI through terminal software, including the free
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
You can also use loops and Bash scripts with WP-CLI to build more advanced, automated workflows — performing bulk updates, managing multiple sites, and streamlining complex WordPress maintenance tasks with a single command.
How to manage WordPress plugins with WP-CLI
wp plugin is a handy command for interacting with plugins on a site via WP-CLI.
It lets you install, update, and delete plugins using commands rather than navigating multiple steps in WP Admin — and saves you a lot of time.
For example, if you often set up new sites and have a list of plugins from the WordPress.org Plugin Directory that you always install, you can achieve this with a single time-saving command.
You can also easily update plugins you’ve installed from the WordPress.org Plugin Directory from the command line. Switching to different versions of a plugin, including older versions, from the command line is straightforward, too.
Finally, you can install and update plugins from other sources using WP-CLI. This won’t work for all plugins, as you’ll need to enter their URL, and WP-CLI must be able to access the ZIP file. However, if the files are accessible, then you should be able to install them.
Let’s have a look at some of the most useful wp plugin commands.
wp plugin list
Use the following command to see which plugins are installed on the site:
wp plugin list
This command not only lists all the plugins installed on the site, but also displays their status, version number, and whether an update is available.
You can add flags to the wp plugin list command to modify what it returns, such as:
wp plugin list --update=availableThis command will only list the plugins that have an update available.
You can see all the flags available for a specific command by adding the –help flag to it.
For example:
wp plugin list --helpwp plugin update
If the site you’re working on has plugins installed that are hosted in the WordPress.org Plugin Directory and have an update available, they can be updated using the following command:
wp plugin update --allYou can exclude plugins from the update by using the –exclude flag:
wp plugin update --all --exclude=edit-flowExcluding a plugin can be useful if you haven’t tested the latest version of a plugin and don’t want to install it.
As you can see below, all plugins have been updated, except for Edit Flow, as requested.
wp plugin install
WP-CLI can be used to install plugins hosted in the WordPress.org Plugin Directory.
You can also install plugins by entering the path to a local zip file or a URL to a remote zip file.
To install one or more plugins from the WordPress.org Plugin Directory, use the following command appended by the name of the plugin(s):
wp plugin install <plugin-name>For example, to install BuddyPress and Contact Form 7, enter:
wp plugin install bbpress contact-form-7
When entering the name of the plugin, you must use the plugin’s slug in the WordPress.org Plugin Directory.
To find the plugin’s slug, visit the plugin page in the WordPress.org Plugin Directory and locate the slug in the URL:
Image: WP-CLI-slug-example-oneIf you’d like the plugins also to be activated after installation, add the –activate flag to the end of the command:
wp plugin install bbpress contact-form-7 --activateIf a plugin update causes errors, you can roll it back to a previous version using the command:
wp plugin install <slug> --version=1.2.3This reinstalls the specified version of the plugin, letting you revert safely to a stable version.
You can find more information about installing plugins, including instructions on how to install plugins not listed in the WordPress Plugin Directory, on the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
wp plugin deactivate
You can also deactivate one or more plugins from the command line.
This can be especially useful if the site has become unresponsive due to a plugin-related issue that’s preventing you from accessing WP Admin and deactivating the plugin via the browser.
Some of your options for deactivating plugins include deactivating a specific plugin by name, using the –all flag to deactivate all plugins, and deactivating all plugins except for specific ones.
For example, to deactivate a specific plugin, use the following command:
wp plugin deactivate akismetTo deactivate all plugins, use this command:
wp plugin deactivate --allTo deactivate all plugins except for specific plugins, use the following command:
wp plugin deactivate --all --exclude=akismet,hello-dollyYou can view the other options in the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
How to manage WordPress posts using WP-CLI
You can also work with posts and pages using WP-CLI.
wp post list
First up, you can quickly get a list of all posts on a site using the following command:
wp post list
To see a list of pages, add this flag to the command:
wp post list --post_type=pageYou can see a list of posts and pages using this command:
wp post list --post_type=page, postThe
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
wp post create
As you might expect, the wp post create command lets you create posts and pages with WP-CLI.
If you regularly set up new sites that include the same set of pages, such as about, contact, and services pages, you can quickly create those pages using a single command.
For example, the following command will create a post with the title “Created Using WP-CLI.”
wp post create --post_title="Created Using WP-CLI"To create more than one post, you can chain multiple commands together using &&:
wp post create --post_type=page --post_status=publish --post_title='Home' && wp post create --post_type=page --post_status=publish --post_title='About' && wp post create --post_type=page --post_status=publish --post_title='Contact'
By default, new posts are saved as drafts.
However, you can change this by using the –post_status= flag and adding a command, such as publish, draft, or pending.
For example, to create a new post with the title “Created Using WP-CLI” with its status set to published, use the following command:
wp post create --post_title="Created Using WP-CLI" --post_status=publishYou can also add content to the post, assign an author, set the publish date, and more by using the appropriate flags.
More information about the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
wp post generate
If you’re starting a new site and want to populate it with placeholder content, then the wp post generate command will come in handy.
This command is deal for creating test content for a new site design or populating a site with thousands of posts to test performance.
It creates multiple posts with a single command.
Like with other commands, you can add flags to the wp post generate command.
wp post generate --count=10Other flags that can be used with wp post generate include: –post_type=, –post_status=, –-post_author=, and –post_date=.
For example:
wp post generate --count=10 --post_type=page --post_status=draft --post_author=1 --post_date="2025-01-15 12:15:00"The above command will create 10 draft pages by the author with ID 1 with the creation date and time set to January 15, 2025, 12:15 pm.
You can find out more about the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
wp post update
You can also update or change existing posts using WP-CLI.
The wp post update command flags let you update the title, body, excerpt, publish date, status, and author.
As you can update multiple posts at once, this command is useful for changing the status for multiple posts from published to draft or assigning a different user as the author.
When updating multiple posts with a single command, you must refer to the posts using their ID. To see the IDs for each post, use this command:
wp post listOnce you have the IDs for each post you want to update, you can refer to them in the command, separated by a space.
Here’s an example of a wp post update command that updates multiple posts:
wp post update 14 16 19 --post_author=52288503This command changes the author of the posts with IDs 1, 125, and 283 to the user with ID 2.
(To view the list of users and their IDs, use the wp user list command.)
To build upon that command, if you wanted to change the author of all posts by a specific author to a different author, you could use this command:
wp post update $(wp post list --post_author=52288503 --format=ids) --post_author=52288502
This command retrieves a list of all posts authored by the author with author ID 52288503, then updates or changes them so that the author is now the one with ID 52288502.
You could use the same approach to change the status of all published posts to draft by using this command:
wp post update $(wp post list --post_status=publish --format=ids) --post_status=draftYou can see what else is possible with this command on the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
wp post delete
Deleting posts is another task that you can carry out with WP-CLI.
Again, the post IDs are used when specifying which post(s) to delete:
wp post delete 649
To delete multiple posts, separate the IDs with a space:
wp post delete 649 300 150By default, posts are moved to the trash. However, you can use the –force flag to skip the trash folder and delete the post:
wp post delete 648 --force
If you want to delete all pages, you can use the following command:
wp post delete $(wp post list --post_type=page --format=ids)
This command deletes all posts by a specific user:
wp post delete $(wp post list --post_author=2 --format=ids)
How to manage WordPress themes with WP-CLI
The wp theme commands also let you carry out several theme-related tasks on a site.
wp theme list
To quickly view a list of all themes on the site, along with their status, whether an update is available, and the version number, enter the following command:
wp theme list
wp theme activate
You can activate a specific installed theme using the following command:
wp theme activate twentytwenty
wp theme install
Like plugins, you can install themes from the command line.
If you want to install a theme from the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Like plugins, the slug is in the URL of the theme’s page in the WordPress Theme Directory.
For example, if you want to install the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
wp theme install hello-biz
If you want to activate the theme after installing it, add the –activate flag:
wp theme install twentytwentyfour --activatewp theme update
A single command can update all of the themes that have an available update:
wp theme update --allYou can also exclude themes from the update by using the –exclude flag:
wp theme update --all --exclude=twentytwentyHow to manage WordPress comments with WP-CLI
Besides, the wp comment command gives you a quick way to view and delete spam comments on the site, as well as interact with comments in other ways.
You can see the comments on a site by using the following command:
wp comment listHowever, this doesn’t always include spam comments in the list. To see spam comments, use this command:
wp comment list --status=spamThen, to delete the spam comments, use the wp comment delete command with the wp comment list command:
wp comment delete $(wp comment list --status=spam --format=ids)Developer-recommended WP CLI commands
Here are some additional commands that can help you manage and troubleshoot WordPress sites:
wp cache flush
You can manage a WordPress site’s cache using the wp cache command.
wp cache flush is useful as it can fix issues where site changes, such as post edits, theme updates, or settings changes, aren’t displayed.
WordPress automatically regenerates the cache the next time the site is loaded, ensuring the most up-to-date version is shown.
The WordPress Developer Resources has more information on the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
wp db export
You can also perform database operations with WP-CLI.
The wp db export command creates a backup of your WordPress database as an .sql file — something that’s worth doing before making major site changes. You can also use WP-CLI to export specific tables, exclude tables, or import a database file.
More information about the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
wp rewrite flush
The wp rewrite flush command refreshes WordPress’s permalink structure and rewrite rules. It can fix 404 errors that occur after adding custom post types or changing permalink settings.
You can find out more about this command in the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
wp search-replace
The wp search-replace command lets you search for a string in your WordPress database and replace it with another.
It’s especially useful for updating URLs after a site migration or correcting text across posts, pages, and settings. Using the –dry-run flag lets you preview changes before applying them.
An example of this command would be:
(add grey box/background
wp search-replace 'energise' 'energize' --dry-runThis command previews all instances of energise that would be replaced with energize. If you’re happy with the output, you can run the same command without the –dry-run flag to apply the changes.
The above are just a few examples of how you can use WP-CLI to interact with your WordPress site outside of the WP Admin interface.
Hopefully, this has inspired you to start interacting with WordPress from the command line.
For more information on using WP-CLI, check out
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Cool WordPress.com-specific WP-CLI commands
WP-CLI is included with the WordPress.com
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Some core commands aren’t supported, but there are a few others that are exclusive to
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
1. wp –help
To see exactly what’s available on the WordPress.com Business and Commerce hosting plans, enter the following command:
wp --helpDoing so will reveal all of the WP-CLI commands available to your site based on your plan.
2. wp wpcomsh diag
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
One such command is wp wpcomsh diag.
This command runs site diagnostics tests and outputs the results, including the status of plugins, accounts with administrator access, details of active WordPress.com hosting plans and services, critical PHP errors, and more.
It’s a quick and easy way to get a detailed overview of a site’s status.
3. wp wpcomsh plugin-dance
If there are errors on the site, the following command disables all plugins and enables them one by one to check if a specific plugin is causing the issue:
wp wpcomsh plugin-danceYou can also
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
For more WordPress.com-specific WP-CLI commands, check out the complete list in the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
As you can see, being able to use WP-CLI is another reason why WordPress.com isn’t just for hosting simple blogs; it’s a developer-friendly platform with advanced tooling.
Learn more about WP-CLI
There’s a lot more you can do with WP-CLI, from checking out the full list of commands to
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
You can also create Bash scripts that contain multiple WP-CLI commands. Then, instead of running each command individually, you can run the entire script at once.
For example, you could create a Bash script called update.sh that includes WP-CLI commands to update all plugins and themes:
Kod:
wp plugin update --all
wp theme update --all
You can then run the script with ./update.sh. The script’s contents will execute, which in this case, will update the themes and plugins on the site.
That’s just a sample of what’s possible with WP-CLI. To learn more,
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Ready to start using WP-CLI?
WP-CLI is a great tool for developers and site owners who want more control over their site while spending less time clicking around in WP Admin.
The biggest hurdle to getting started is usually a mental one.
In most cases, opening your terminal software and logging in for the first time takes only a few minutes. After that, you’ll have a faster, more efficient way to manage your site.
Beyond its speed and efficiency, WP-CLI offers other practical advantages.
You can deactivate plugins and themes, toggle settings when WP Admin is inaccessible, and even generate dummy content with a single command.
To try it out, sign up for the
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Another useful tool to explore is
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.
Bu bağlantı ziyaretçiler için gizlenmiştir. Görmek için lütfen giriş yapın veya üye olun.