February 7, 2018
#PHP #WordPress #WP_Query
WP_Query is typically much safer than using SQL directly in a WordPress environment. But probably less intuitive. I always have to look up what the various arguments actually represent. So this post is to remind me of the basic syntax and structure.
In the first example, from a recent project, we are returning all products which are watches – where
client_product is a
Custom Post Type. In the second, within a
Switch, we are returning a specific selection (from a dropdown).
Remember to call