Trevan Hetzel

Prevent widows in WordPress custom fields

I use Advanced Custom Fields on nearly every client site I develop. One thing that’s kind of not cool about user generated content is the lack of control over non-breaking spaces between the last two words to prevent widows. But fear not! With this regex snippet from David Walsh, you can create a helper function in your custom theme and wrap all your ACF output (or just static text) in the helper that will insert...

Continue Reading

An introduction to Stimulus

Stimulus was released in 2018 by the Basecamp team. Its motto is “A modest JavaScript framework for the HTML you already have.”. It sounded catchy (and lead by DHH) so I wanted to play around with it and see what it was all about and how it stacks up to more modern reactive frameworks like Vue and React (spoiler alert: it is not at all similar to Vue or React). After playing around with it,...

Continue Reading

Simple animated sticky header with plain JavaScript and CSS

Sticky headers are a very common pattern found on a lot of websites. You see lots of site headers that stick to the top of the page once the user scrolls down to a certain point (usually the height of the header). Since it’s such a common UX pattern, there are lots of libraries, plugins and different ways to build them. But I hate adding libraries to my codebases when just a few lines of...

Continue Reading

My essential front-end extensions for Visual Studio Code

I’ve recently switched from Sublime Text to Visual Studio Code as my primary code editor. As such, I’ve personalized it to feel like home. Here are the most important extensions I use as a front-end developer. Afterglow Remastered This is the color theme I’ve been rocking in Sublime Text for a while, so I was pretty happy to discover it had been ported over to Visual Studio Code. Auto Close Tag Because who doesn’t want...

Continue Reading

Loading stylesheets in WordPress child themes the fast way

Loading stylesheets in WordPress child themes is a pretty straightforward process. According to the Codex, you just add a wp_enqueue_scripts action that loads the parent theme’s stylesheet as well as the child theme’s stylesheet. Easy peasy. However, you know me and extra asset requests 😉 I hate to request multiple CSS or JS files if I can help it. Loading the parent stylesheet with WordPress’ recommended wp_enqueue_scripts is going to end up making two calls...

Continue Reading