Cheat Code #1: Setting WordPress Options with WP-CLI

Reading Time: < 1 minute

You’re seeing this a month later than you could have. Sign up now to get development Cheat Codes just like this delivered directly into your inbox each week.

I’m going to try something new with the newsletter. I’ll be sharing cheat codes you can use to get an advantage in WordPress and development in general. It won’t quite be up, up, down, down, left, right, left, right, b, a, start, but it will get the job done.

The first, inspired by the infamous Discourage Search Engines being left on a client’s site and throttling SEO, is to quickly check if search engines are allowed via the CLI.

wp option get blog_public

If this returns 0. It means your blog is not public and Discourage Search Engines is active and you’re losing out on that sweet SEO goodness. If you need to turn off Discourage Search Engines you can use:

wp option update blog_public 1

That sets blog_public to true. Meaning discourage search engines is turned off.

For super powers combine this with wp-cli aliases and you can check all the sites you manage with a single command like wp @aliasgroup get blog_public.

Pin It on Pinterest