Selecting DISTINCT Records in WordPress
read more
Categories

Selecting DISTINCT Records in WordPress


If you need to write a query against the WordPress database, grab a reference to $wpdb and get to work, right? In some instances, sure. I’m not opposed to this. After all, the API exists for a reason. But sometimes, I think we bypass built-in APIs. We go straight for $wpdb without looking to see if other hooks already exist.

If a hook exists, why not use it? It’s one level of abstraction above the database and it uses the native API. As mentioned in a previous post, I want to cover a few ways to customize queries that run against the database.

Case in point: selecting DISTINCT records from WordPress.