David Walsh Tutorials
![Sort Objects by Property with PHP]()
Sort Objects by Property with PHP
I recently needed to display a list of authors within a WordPress blog. The goal was to sort the author list by number of posts before outputting the list. The method for calculating number of posts isn't a sortable key within WordPress'
get_posts, so I had...![Add and Remove Profile Fields to WordPress User Form]()
Add and Remove Profile Fields to WordPress User Form
The WordPress user profile screen allows you to set values for social services but some default services are irrelevant, namely AIM and Yahoo! IM; add to that the fact that Twitter and Facebook fields are missing. You quickly realize that the default form...needs work. WordPress provides...
![Create xkcd-Style Comics with Comix]()
Create xkcd-Style Comics with Comix
Everyone loves the epic comic xkcd. These comics aren't usually masterclasses of artwork but expressions of whit, usually of a tech-related subject. I've always thought I could eventually create witty comics but never had the illustration skills to bring them to fruition. Luckily an incredible...
![Detect Unmatched CSS Selectors with Helium]()
Detect Unmatched CSS Selectors with Helium
One thing I can't stand is extra code. Whether it's an extra CSS or JavaScript file that's been included by the page, bloated HTML, or unoptimized images, we're making our millions of of desktop and mobile visitors pay for our laziness and mistakes. A great tool...
![Create WordPress Shortcodes]()
Create WordPress Shortcodes
WordPress shortcodes are super handy, especially when handing off a WordPress-based website to a client. The alternative to using shortcodes is creating complicated templates, and even then, you cannot adequately replace what shortcodes can do. I recently needed to implement a new...
![Override WordPress URL]()
Override WordPress URL
When I migrated my website between Media Temple servers, I wanted to manually test the site to ensure no server configuration differences between the server were bricking the site. The obvious problem I would encounter is that links would be broken because the site wasn't...
![parseInt and Radix]()
parseInt and Radix
Everyone knows that the parseInt function within JavaScript turns your decimal number or string into a rounded integer.
parseIntturns 10.937 into 10, 0.2 into 0, and "someValue" intoNaN. If you useparseIntwithout a radix, however, you'll receive a warning that no radix has...![Hide the Admin Bar in WordPress]()
Hide the Admin Bar in WordPress
WordPress automatically injects an admin toolbar at the top of the page for logged in users. This bar is really an annoyance to me because it slightly throws off my theme design and I never need the toolbar for anything. Here's a snippet of code which...
![CSS @supports]()
CSS @supports
Feature detection via JavaScript is a client side best practice and for all the right reasons, but unfortunately that same functionality hasn't been available within CSS. What we end up doing is repeating the same properties multiple times with each browser prefix. Yuck. Another thing we...
![Get Pseudo-Element Properties with JavaScript]()
Get Pseudo-Element Properties with JavaScript
CSS pseudo-elements are incredibly useful -- they allow us to create CSS triangles for tooltips and perform a number of other simple tasks while preventing the need for additional HTML elements. To this point, these pseudo-element CSS properties have been unreachable by JavaScript but now...







