{"id":1429,"date":"2022-03-14T13:25:42","date_gmt":"2022-03-14T13:25:42","guid":{"rendered":"https:\/\/neoxea.com\/blog\/?p=1429"},"modified":"2023-12-17T19:29:24","modified_gmt":"2023-12-17T19:29:24","slug":"wp-cli","status":"publish","type":"post","link":"https:\/\/neoxea.com\/blog\/wp-cli\/","title":{"rendered":"What is WP-CLI"},"content":{"rendered":"\n<p>WP-CLI<strong> <\/strong>allows you to do multiple things like updating your WordPress, installing themes and plugins, without using a web browser. To take advantage of the tool you don\u2019t need to install anything yourself. Simply login to your account via SSH, navigate to the folder of your WordPress installation and run the commands \u2013 it\u2019s that simple!<\/p>\n\n\n\n<p>We are super excited to announce that a new WordPress tool is now available on all our servers.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>WordPress users who love command line will be happy to find WP-Cli available on all <a href=\"https:\/\/neoxea.com\/pricing\">Neoxea Hosting Plans<\/a>.<\/p>\n<\/blockquote>\n\n\n\n<p>To learn how to use WP-CLI you can refer to our WP-CLI tutorial. Additionally, you can find a full list of WP-CLI commands on their official website.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-useful-examples\">Useful Examples<\/h2>\n\n\n\n<p>We recommend looking at the <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">commands list<\/a>, try some of them out. We will take a look at some useful options in order to get you started.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"h-install-wordpress\">Install WordPress<\/h6>\n\n\n\n<p>We use WP-CLI a lot to set up test environments, the first step of which is a vanilla installation. Here is a list of commands we run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp core download\nwp core config --dbname=mydbname --dbuser=mydbuser --dbpass=mydbpass --dbhost=localhost --dbprefix=whebfubwef_ --extra-php &lt;&lt;PHP\ndefine( 'WP_DEBUG', true );\ndefine( 'WP_DEBUG_LOG', true );\nPHP\nwp db create\nwp core install --url=http:\/\/siteurl.com --title=SiteTitle --admin_user=myusername --admin_password=mypassword --admin_email=my@email.com<\/code><\/pre>\n\n\n\n<p>The most recent version of WordPress is downloaded using the first command. The second command sets up the config file with the database access and some additional PHP at the end. The additional constants make sure we have our debugging options on for testing.<\/p>\n\n\n\n<p>The third command creates the database (WP-CLI uses the database access info from the config file) and finally, we install WordPress using a couple of parameters.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"h-re-install-wordpress-core\">Re-install WordPress Core<\/h6>\n\n\n\n<p>You can also reinstall WordPress core using WP-CLI. The following command would download WordPress core without the default themes and plugins.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp core download --skip-content --force<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"h-list-plugins\">List Plugins<\/h6>\n\n\n\n<p>To get a list of current plugins installed on a website simply use the following command. In this example, you can see we have the Akismet and Yoast SEO plugin installed. It will also return the status (active\/deactivated), if there is an update available, and the current version.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp plugin list<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"h-install-plugins\">Install Plugins<\/h6>\n\n\n\n<p>To install multiple plugins you can simply add parameters. Here\u2019s an example that downloads and activates 2 plugins:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp plugin install akismet wordpress-seo --activate<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"h-update-plugins\">Update Plugins<\/h6>\n\n\n\n<p>You can also manually update WordPress plugins. Example below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp plugin update akismet wordpress-seo<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"h-delete-transients\">Delete Transients<\/h6>\n\n\n\n<p>You can even delete and clear out one or all transients using the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp transient delete --all<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"h-delete-revisions\">Delete Revisions<\/h6>\n\n\n\n<p>On large sites, WordPress revisions can add up very quickly to hundreds or thousands of rows in your database which are not needed. You can delete post revisions with WP-CLI. Here is an example of the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp post delete $(wp post list --post_type='revision' --format=ids)<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"h-change-wordpress-url\">Change WordPress URL<\/h6>\n\n\n\n<p>There are many reasons why you might need or want to change your WordPress URL. Perhaps you are changing domains, moving to a subdomain, updating from www to non-www, moving files around, or even migrating from HTTP to HTTPS. Whatever the case may be, you can use easily use the wp option update command for this. Here is an example below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wp option update home 'http:\/\/example.com'\nwp option update siteurl 'http:\/\/example.com'<\/code><\/pre>\n\n\n<style>.kb-row-layout-id1958_9b7b8d-00 > .kt-row-column-wrap{align-content:start;}:where(.kb-row-layout-id1958_9b7b8d-00 > .kt-row-column-wrap) > .wp-block-kadence-column{justify-content:start;}.kb-row-layout-id1958_9b7b8d-00 > .kt-row-column-wrap{column-gap:var(--global-kb-gap-md, 2rem);row-gap:var(--global-kb-gap-none, 0rem );padding-top:var(--global-kb-spacing-sm, 1.5rem);padding-bottom:var(--global-kb-spacing-sm, 1.5rem);grid-template-columns:minmax(0, 1fr);}.kb-row-layout-id1958_9b7b8d-00 > .kt-row-layout-overlay{opacity:0.30;}@media all and (max-width: 1024px){.kb-row-layout-id1958_9b7b8d-00 > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}@media all and (max-width: 767px){.kb-row-layout-id1958_9b7b8d-00 > .kt-row-column-wrap{grid-template-columns:minmax(0, 1fr);}}<\/style><div class=\"kb-row-layout-wrap kb-row-layout-id1958_9b7b8d-00 alignnone wp-block-kadence-rowlayout\"><div class=\"kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top\">\n<style>.kadence-column1958_62eb2d-49 > .kt-inside-inner-col,.kadence-column1958_62eb2d-49 > .kt-inside-inner-col:before{border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;}.kadence-column1958_62eb2d-49 > .kt-inside-inner-col{column-gap:var(--global-kb-gap-sm, 1rem);}.kadence-column1958_62eb2d-49 > .kt-inside-inner-col{flex-direction:column;}.kadence-column1958_62eb2d-49 > .kt-inside-inner-col > .aligncenter{width:100%;}.kadence-column1958_62eb2d-49 > .kt-inside-inner-col:before{opacity:0.3;}.kadence-column1958_62eb2d-49{position:relative;}@media all and (max-width: 1024px){.kadence-column1958_62eb2d-49 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}@media all and (max-width: 767px){.kadence-column1958_62eb2d-49 > .kt-inside-inner-col{flex-direction:column;justify-content:center;}}<\/style>\n<div class=\"wp-block-kadence-column kadence-column1958_62eb2d-49\"><div class=\"kt-inside-inner-col\"><style>.wp-block-kadence-spacer.kt-block-spacer-1958_649432-7f .kt-block-spacer{height:60px;}.wp-block-kadence-spacer.kt-block-spacer-1958_649432-7f .kt-divider{border-top-width:5px;height:1px;border-top-color:#3293e3;width:10%;border-top-style:solid;}<\/style>\n<div class=\"wp-block-kadence-spacer aligncenter kt-block-spacer-1958_649432-7f\"><div class=\"kt-block-spacer kt-block-spacer-halign-left\"><hr class=\"kt-divider\"\/><\/div><\/div>\n\n\n\n<p>Save time and money, plus make your website go faster with our next-generation cloud platform available in every Managed WordPress plan. This includes a high-performance web server, DDoS protection, malware and email spam mitigation, a free cache plugin, and the world&#8217;s fastest AMD CPU machines. Get started with no long-term contracts, free migrations, and a 30-day money-back guarantee.<br>Check out our <a href=\"https:\/\/neoxea.com\/pricing\/\">plans<\/a> or talk to <a href=\"https:\/\/neoxea.com\/contact-us\/\">sales<\/a> to find the right plan for you.<\/p>\n<\/div><\/div>\n\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>WP-CLI allows you to do multiple things like updating your WordPress, installing themes and plugins, without using a web browser. To take advantage of the tool you don\u2019t need to install anything yourself. Simply login to your account via SSH, navigate to the folder of your WordPress installation and run the commands \u2013 it\u2019s that&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2257,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"default","_kad_post_title":"default","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[27],"tags":[],"class_list":["post-1429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress"],"taxonomy_info":{"category":[{"value":27,"label":"WordPress"}]},"featured_image_src_large":["https:\/\/neoxea.com\/blog\/wp-content\/uploads\/wp-cli.png",600,300,false],"author_info":{"display_name":"Rodolfo","author_link":"https:\/\/neoxea.com\/blog\/author\/blogxea\/"},"comment_info":0,"category_info":[{"term_id":27,"name":"WordPress","slug":"wordpress","term_group":0,"term_taxonomy_id":27,"taxonomy":"category","description":"","parent":0,"count":13,"filter":"raw","cat_ID":27,"category_count":13,"category_description":"","cat_name":"WordPress","category_nicename":"wordpress","category_parent":0}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/posts\/1429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/comments?post=1429"}],"version-history":[{"count":0,"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/posts\/1429\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/media\/2257"}],"wp:attachment":[{"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/media?parent=1429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/categories?post=1429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/neoxea.com\/blog\/wp-json\/wp\/v2\/tags?post=1429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}