Setting up WordPress in 2023

Here is my recipe for quickly spinning up a WordPress site with:

  • Plugins and themes managed by PHP Composer, so they can be checked into version control.
  • Several of my favourite plugins installed, including FooGallery and Advanced Custom Fields.
  • A minimal theme combining Roots Sage 10 and Bootstrap 5.2 (at the time of writing this article 5.3 was an alpha release). and making use of the plugins in places.
  • Avoiding shiny WYSIWYG things like the WordPress block editor, page builder GUIs, etc.

Assumptions

  • You have SSH access to a Linux+Apache web host
  • You have a blank MySQL/MariaDB database
  • PHP and PHP Composer are installed and working on the web host, along with any optional components WordPress and Roots Sage need
  • You have a domain name (or subdomain) pointed at the host
  • Node JS, npm, and yarn are installed and working on the web host
  • git is installed and working on the web host

WordPress Setup

Let’s clone a skeleton site from Github. This includes our composer.json file along with a minimal index.php and an example wp-config.php file.

cd $HOME/sites/test.site.example
git clone https://github.com/tobyink/wp-base2023.git .
composer install
cp wp-config.php.example wp-config.php

Now we edit wp-config.php to add:

  • The domain name
  • Database connection info
  • Fresh salt from here

That should be enough for us to be able to visit https://$domain/wordpress/wp-admin/ in a browser and complete WordPress’s browser-based setup procedure.

Theme Setup

My minimal theme is called Thyme. It’s based on Roots Sage 10 and is pretty flexible in terms of appearance.

If you plan on using a different theme, you can skip straight to the conclusion.

To install Thyme:

cd $HOME/sites/test.site.example
cd wp-content/plugins/
git clone https://github.com/roots/acorn.git acorn
cd acorn
git checkout 2.x
composer install
cd ../../..
git clone https://github.com/tobyink/wp-thyme-theme.git thyme
cd wp-content/themes/
ln -s ../../thyme/ thyme
cd ../../thyme/
composer install
yarn install
yarn build
chmod -R ugo+rwX public/ resources/styles/common/_wp_theme.scss

Yes, that’s a fair few commands, but don’t let them scare you.

Once it’s installed, go to Plugins in the WordPress backend and make sure the following key plugins are activated (because the theme needs them!):

  • Acorn
  • Advanced Custom Fields
  • Classic Editor

Only after activating these plugins should you activate the theme.

Some optional features of the theme require these plugins to be activated:

  • Breadcrumb NavXT
  • FooGallery

After activating the theme, you can use the Theme Options and Sections forms in the backend to customize site appearance. After making any changes, all your CSS and Javascript files are automatically recompiled.

(There’s currently a bug in Thyme where recompilation is broken until you’ve gone to Theme Options and Sections and hit “Update” on both. This is because there’s a few nulls hanging around in the default values which breaks SASS syntax causing CSS compilation errors. Visiting both pages and setting some values flushes out the nulls.)

Conclusion

This is a pretty simple way to set up an easily-manageable no-nonsense WordPress blog.