October 2019

Use WP CLI to tinker with your codebase via an interactive shell

If you have access to WP CLI I can’t recommend it enough. Since I picked it up it has saved me so much time during development. It helps me scaffold code, analyse the installation, update core and plugins, and it even helps me test code on the fly. Testing code on the fly with wp […]

October 2019

How to get Advanced Custom Fields to load JSON files from more than one directory

If you use Advanced Custom Fields a lot you are probably using ACF’s very awesome Local JSON feature. By default, ACF saves and loads all JSON files from the acf-json directory inside your theme but it is possible to take control of ACF’s behaviour to define your own custom load points as outlined in the […]

October 2019

Use closures for basic encapsulation when writing jQuery

If you are writing a lot of jQuery you’ll likely have files with loads of JavaScript functions and variables that may be completely independent and shouldn’t interfere with each other. If you have a lot of this going on (or even if you don’t) you might consider wrapping up related variables & functions using closures […]

October 2019

A function for temporarily changing the WordPress post context

If you’ve ever found yourself in a situation where you need to render something from some other post whilst in the context of another, you may have ended up just overriding the global $post variable. It works fine but can be problematic where you mess it up or just forget to clean up after yourself. […]

October 2019

Get an ACF sub-field key by field name

Having written plugins that extend the very popular WordPress plugin Advanced Custom Fields (ACF), I’ve come up against the need to work out a field’s key based on its field name. This normally comes up when structuring data for programmatic field update as ACF needs to the values mapped to field keys when updating complex […]

October 2019

A utility CSS class for removing margins on first and last child elements.

I’ve recently been developing sites using a utility-based approach with my CSS and I’m kinda loving the flexibility that comes with this paradigm. One particularly useful class I seem to use a lot is one that removes margins from the first and last elements within a container. I use this a lot because I tend […]

October 2019

How to automatically version WordPress assets using their last modified time

Versioning your assets in WordPress is relatively straight-forward as the wp_register_script() and wp_register_style() functions both offer support for specifying a version as a function parameter. It’s easy to use because you simply pass it a value but it’s also simple to forget which could result in site visitors loading up stale versions of CSS and […]

August 2019

How to bypass Elementor’s maintenance mode using the query string

I recently found myself in a situation where I needed to test the non-logged in user experience while Elementor’s maintenance mode was enabled. The quick and easy solution I came up with was to override the option Elementor uses to enable maintenance mode when the query string contained a parameter of my choosing. Using the […]

August 2019

How to render WordPress menu items without a custom Walker

In recent work where I’ve been using tailwindcss to build my UI, I’ve come up against the challenge of dealing with WordPress’ default menu markup. One possible solution here could be to write a custom walker class but, for something quick and simple, the following code snippet got me where I needed to be with […]

March 2019

Pushing Gist changes back up to Github

So this has kind of caught me a few times and thought I might stick it here as a future note to self. When attempting to push to a Gist using SSH authentication, the remote host needs to be in the format that support SSH. e.g; [email protected]:xxxxxxxxx.git Command to check: git remote v If the […]