Category: Development

  • Speed Up Your Genesis Theme by Reducing Database Queries

    WordPress ships with a bunch of nifty methods to improve performance and knowing when to use one of them could cut the number of database queries on your site by over 60%.

    Post Thumbnail Caching

    It has to do with the way post thumbnails are displayed in a loop.

    By default, whenever get_the_post_thumbnail() is called in the main loop for the first time, WordPress looks up data for all thumbnails that are likely to appear and caches them. Otherwise, the thumbnail data for each post needs to be fetched on each iteration of the loop at a cost of two additional queries per thumbnail: One for the attachment and one for the attachment’s meta data.

    So what exactly is the method? It’s a simple function, aptly named update_post_thumbnail_cache(). (more…)

  • A WordPress Class Template Tag to Rule Them All

    Last week, on Twitter…

    Yes, I know, that’s the beginning of a terrible blog post. But really, a tweet by Jonathan Christopher piqued my curiosity last week:

    https://twitter.com/jchristopher/status/273437718653050880

    SMACSS? I hadn’t heard of it and figured it was probably some Mac-only app, but looked it up anyway. Lo and behold, it was actually interesting. I haven’t really changed the fundamentals of the way I write CSS for a couple of years, don’t use a pre-made grid, and have yet to adopt a pre-processor.

    (more…)

  • Abstracting Custom Post Type and Taxonomy Registration In WordPress

    Custom Post Types in WordPress are incredibly useful, but as a web developer working on a number of projects at any given time, it can be frustrating having to manually write out each and every label needed for display throughout the dashboard.

    While reviewing plugins and other projects, I’ve seen developers build libraries to abstract away a lot of the mundane details of creating CPTs by dynamically generating default arguments and labels. Unfortunately, there are a few pitfalls with this approach that don’t make it a viable option:
    (more…)

  • Treasure Hunting In WordPress Core

    As WordPress organically evolves based on the needs of the community — from blogging engine, to content management system, and toward an app platform — it’s become ever more important that its default behavior can be modified to suit a wide range of demands. The primary means of making customizations is through the use of hooks, which consist of actions for executing functionality at a specific point in time, and filters for modifying data passed through them. Plugins and themes take advantage of this system to extend WordPress in an unlimited number of ways.

    One of my very first plugins simply limited the length of post titles so they didn’t break the design if they were too long. We’ve all come a long way since then!

    (more…)