WordPress Tutorials

Contextual customize partials

While building the Exhale theme, my latest WordPress project, I wanted to build a cool feature into the customizer. The idea was that the user would have an option to select their preferred featured image size. When selecting a size, their featured images would be refreshed in the preview panel … Continue reading →

Whitelist validation in WordPress

Far too often when doing code reviews, I see developers lean too heavily on sanitize_text_field(), using it as a sort of catchall for sanitizing data. That’s usually not a good idea. Data should be sanitized based on what sort of data you’re expecting. In this tutorial, I’m going to cover … Continue reading →

PHP Namespaces For WordPress Developers

It seems like ages ago when I stopped working with PHP 5.2, which is currently the minimum version to run WordPress. One of the primary reasons for this for me as a developer was to use PHP namespaces, introduced in PHP 5.3. There are many other useful features brought to … Continue reading →

Settings wrappers for plugins and themes

I’ve seen many methods of retrieving settings in themes and plugins over the years. Everything from an object property buried somewhere I can rarely find to a global variable wrapped by a function set up by a global variable. Suffice it to say, I’ve seen it all. Over time, I’ve … Continue reading →

How to remove the customizer CSS option

Now that WordPress 4.7 has been released, most people will notice an “Additional CSS” section in the customizer when they update. This is an awesome feature and a perfect use of the customizer. It’ll be great for the vast numbers of users who just need to add some basic CSS … Continue reading →

Using WP_Query properties instead of an iterator

Sometimes, when running through a post loop, theme authors need to do something special, depending on the current post in the loop or the total post count. For example, displaying ad space between the first and second post. Or, as in the screenshot above, displaying posts with drastically different markup … Continue reading →

Designing better nested comments

I’ve always had a love/hate relationship with nested comments. I like the idea of finding replies to comments without having to scroll up and down the page. I hate how unruly they get when more than two or three levels deep. In my most recent theme, Extant, and the newest … Continue reading →

Post format support for custom post types

When building the Custom Content Portfolio plugin, I needed to add post format support to my portfolio project post type. Generally speaking, this is a pretty easy thing to do. However, I wanted to limit the possible formats to only those that made sense for portfolios. This tutorial will walk … Continue reading →

JavaScript templating in the WordPress customizer

In my previous tutorial on building a radio image control in the WordPress customizer, instead of using PHP to output data for the control output, I used JS. Specifically, this used Underscore’s templating engine that’s packaged with WordPress. While I’m not well-versed in JavaScript, it’s something that will increasingly become … Continue reading →

Customizer radio image control

In this tutorial, I’ll be writing about a radio image control for the WordPress customizer. This was a request, but I honestly don’t remember who asked for it. Sorry for forgetting. I hope you’re following the blog. :) This type of control is also something I’ve needed for a long … Continue reading →