I want to convert a page to homepage. To add widget to homepage I need to do that. How will I be able to do that using WP CLI?
1 Answer
To set the site’s static home page with WP-CLI, you should be able to do something like this:
wp option update show_on_front "page"
wp option update page_on_front {$page_id}
… where {$page_id} is the ID of the page you want to be the front page.
(Your question was originally tagged multisite
—if you’re running a Multisite installation, and want to specify a site other than the main site, you’ll need to do this:
wp option update show_on_front "page" --url=example.com/site
wp option update page_on_front {$page_id} --url=example.com/site
… where example.com/site
is the URL of the site you wish to affect.)
Note: I haven’t tested this code. You should try it on a non-production WordPress installation first to be sure it works as intended.
References
wp option update
- A related answer with the required option names (
show_on_front
&page_on_front
)