2

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?

  • Do you mean the site's static front page, or the site's blog posts page? – Pat J Aug 5 '19 at 2:03
  • I mean the static front page – Tessaracter Aug 6 '19 at 12:22
1

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.