Posts relating to
Dev Tricks
WP Code Tip: get array of post IDs
October 18th, 2018A number of times over my years developing in WordPress I’ve needed to extract the post IDs of the posts in an array. And every time I need to do this I use the wp_list_pluck() function, from WP_List_Util, the WordPress list utility class. And every time I use this really handy helper I mean to […]
Use PHP’s in_array() to compare a variable to multiple values
September 28th, 2018When 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
September 26th, 2018This 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 […]
Setting up PHP composer
August 28th, 2018This article walks through the simple steps for setting up composer. Initially at project level, then, optionally, at the global level. Note: This article is for Mac(Unix)/Linux users, please refer the official docs for Windows. What is Composer? Composer is the dependency manager for PHP packets. In my opinion it should be in every web […]
How to call wp_get_attachment_image() without srcset
August 10th, 2018Sometimes 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 […]