Setting up WordPress in 2023
Tags: wordpress, composer, git, php
Published: 2023-02-07 11:13:12

---
title: Setting up WordPress in 2023
published: true
date: 2023-02-07 10:57:26 UTC
tags: wordpress,composer,git,php
canonical_url: https://toby.ink/blog/2023/02/07/setting-up-wordpress-in-2023/
cover_image: https://toby.ink/wp-content/uploads/2023/02/pexels-pixabay-265667-1024x661.jpg
---

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](https://fooplugins.com/foogallery-wordpress-gallery-plugin/) and [Advanced Custom Fields](https://www.advancedcustomfields.com/).
- A minimal theme combining [Roots Sage 10](https://roots.io/sage/) and [Bootstrap 5.2](https://getbootstrap.com/docs/5.2/getting-started/introduction/) (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](https://api.wordpress.org/secret-key/1.1/salt/)

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](#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.