WordPress Command Line Interface (WP-CLI)

Developing for WordPress in Exeter and Plymouth

WP-CLI is a super-useful command line utility for WordPress developers. Instead of doing everything through the WordPress back-end, or using custom templates to render and debug your code, you can now interact with you site using simple commands from a console.

Developing this way may require an adjustment to your familiar workflow, but the learning curve is not steep, and the trade-off in terms of ease and power is definitely worth it! This post isn’t meant to be a tutorial, but to give you some idea of how easy WP-CLI can make your life, check out how easy installing WordPress becomes with using it:

wp core download
wp core config --dbname=wordpress --dbuser=root --dbpass=root
wp core install --url=http://localhost/dev/wordpress/ --title=WordPress --admin_user=username --admin_password=mypassword --admin_email=myemail@post.com

And that is all. You now have a working installation of WordPress!

Once installed you can run commands like: 

wp post list

to get a list of all posts from your site, or

wp plugin install bbpress –activate

to install and activate bbpress. And much, much more…

The project website is here for more info. I hope you enjoy using this fantastic tool.

For installation on Windows, this is what I did:

  • Install Compser from https://getcomposer.org/ using the Windows Installer
  • Open a command window and type just these two instructions:
    • composer global require wp-cli/wp-cli
    • composer global require psy/psysh
  • Now, navigate to a folder with a WordPress installation, and you can now use all that WP-CLI goodness to your heart’s content!

Other People’s Views

Other People's Views elephant picture

Other People’s Views, sometimes known as other people’s hilltops, is a hugely important concept for all of us to take on regardless of our professions. In software development and business it is as crucial as everywhere else.

The concept has been formalized and is taught by the De Bono Group as part of the CoRT thinking course. However, the basic idea is familiar to everyone – although it wasn’t until surprisingly late in my youth that I really started to take it on.

Examples of its application in the world of web design are almost infinite… I may post some dialogues illustrating this in a future post, but for now, maybe consider that the picture above is perhaps best represented more like the one below.

Other People's Views elephant picture 2

Creating a Custom Template for a Specific Post

Developing for WordPress in Exeter and Plymouth

Quick and Dirty WordPress Development Tip #1

There’s a lot of info out there about custom post types in WordPress. For example, there’s an excellent article here. But what if you only want to tweak the appearance or functionality of a single post? It seems a bit excessive to make a whole new custom post type for a one-off situation.

Enter WordPress’s super-cool file-naming system to the rescue!

Working on a child theme, as you absolutely should be, just create a file with the following format: single-post-{post-title}.php. For example, your file might be named single-post-spain.php. Then you can copy the contents of your parent theme’s single.php file, and make any changes you want. When the post with the named title is displayed, WordPress will automatically use the correct file.

This is similar to the method for displaying custom post types using single-{post-type}.php, but saves you having to make a new post type.

I hope this was helpful. Look out for future quick and dirty WordPress Development tips.