WordPress (WP) has a universal function called `get_posts`, but unfortunately, it doesn’t work in 100% of cases. Sometimes, to get the desired result, you need to manually build an SQL query. I don’t really like doing that, since I don’t know all the ins and outs of WP’s internal mechanisms (such as where and when certain filters should be applied). But when the task requires it, you have to write custom SQL.


