Using specific WP_Query

A few weeks ago I encountered a task to retrieve an I.Ds with specific requirements of a hotel post type we're currently building. Instead of using an SQL script, I challenge myself to use WP_Query instead. Using specific WP_Query I was able to retrieve what I want.

Here's a brief introduction to WP_Query, It's commonly used to pull pages, posts and post types which if you wanted to create custom templates for your site. More details here.

Here's the snippet I used:

Using meta_query I was able to narrow than the results. I've able to retrieve events that is greater or equal to my selected date, which is another great alternative for SQL query.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.