wordpress

WP Transients must be used responsibly

We ran into an interesting issue with WooCommerce at work. First, here is the subject of the support request we got from our hosting provider: The site is generating ~150MB/sec of transaction logs, filling 500GB of diskspace Holy. Shit. A WordPress site should not be generating that much data. 150MB per second? Wow. How? Why? The simple explanation is that there is a bottleneck in WooCommerce with the filtered layer nav query objects using single transient record.

Continue reading →

Order Posts via

A request we are getting more often is to show a list of posts, to elevate some of those posts above others, and to show the posts in a random order. Imagine a post type called "Sponsors". Sponsors are tiered, like "Platinum", "Gold", "Silver", etc. We want the Platinum sponsors to appear before Gold, Gold before Silver, and so on. We don't want to favor one particular Platinum sponsor though, we want them to be randomized but ordered by the tier.

Continue reading →

A WordPress ajax handler for custom themes

Something I have been noodling on is a better way to handle ajax requests in my custom themes. Seems to me that a relatively complex theme ends up with a lot of add_action calls for custom ajax handlers, and this could be simplified/reduced. Every time a new endpoint is required we have to add two new add_action calls to our theme. Maybe a better approach is to write a single ajax endpoint that will route requests to the proper classes/methods?

Continue reading →