/

Blog

Cache jQuery selectors for more efficient JavaScript

Having worked in collaborative and team contexts, I’ve had my fair share of situations where I’m working in amongst someone else’s code. There are plenty of things I could gab on about but one issue I commonly see is duplicate jQuery selectors. Now, for really small scripts, duplicate selectors won’t cause you much heartache. However, […]

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 […]

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. […]

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 […]

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 […]

Got a project? Let's talk.

From website design & SEO through to custom WordPress plugin development. I transform ideas into dynamic, engaging, and high-performing solutions.
Subscribe to get the latest insights & updates in the world of web and how it impacts your business and website.
© 2024 Phil Kurth  |  All rights reserved.