The two music streaming services I often swap between are Spotify and Apple Music. I prefer Spotify for a number of different reasons, the main reason being I like its music discovery algorithm more than any other service. You have your own for your reasons. But every now and then, there’s that case when someone […]
Search: “wp_query” (Page 9 of 29)
We found 145 results for your search.
When building a web application, there are bound to be nuances in which native functionality may not work. You may need custom WordPress pagination.
[…] Further Let’s take this a step further though and say that products do exist and we want to retrieve all of their post IDs. Doing this with WP_Query is pretty easy but let’s say, for kicks, we want to interface with the database directly. Note this is more of an exercise of showing a […]
[…] we’ve also updated the query only to pull back three posts (as per this comment). View the code on Gist. Notice in the code, I’ve also pre-fixed WP_Query with a slash because it’s part of the global namespace. Let’s move into the Display directory and take a look at the Meta Box class. This has also […]
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.
