Posts relating to
Dev Tricks

Use PHP’s in_array() to compare a variable to multiple values

When comparing a variable with multiple values consider using in_array(), instead of complex if expressions. I love clean, easy-to-read code, which is why I am not a fan of if statements with complex expressions. For example, consider the following snippet, which is checking a variable against several values: if ($test_variable === ‘value1’ || $test_variable === […]

How to reindex spotlight on macOS to stop it closing after a few characters

This post is a somewhat off-topic, but for all those of you that are working on Macs, here’s a little tip to reset Spotlight when starts closing after just a few characters. You could try going into System Preferences and adding a drive in the Privacy tab, then removing it, but it didn’t work for […]

How to call wp_get_attachment_image() without srcset

Sometimes it’s nice to have all the goodies wrapped up in a nice little function, such as wp_get_attachment_image(). This is a great function that generates the entire html for an image tag, including srcset and sizes. However, wouldn’t it be great if sometimes we could get all the goodness from this wonderful function, but just […]