Since WordPress' inception back in 2003, it has grown to become one of the most popular web platforms today. As of July 27, 2013, Matt Mullenweg, the co-founder of WordPress, announced it accounts for 18.9% of all the websites today. Mean while, if you were to compare the market share of the CMS' in use today, WordPress accounts for 60.1%. That's pretty impressive if you ask me!
Part of the reason I believe WordPress is so popular successful, is because of how simple and easy it is to get off the ground with it. Whether you are a business owner with no code knowledge or you are a long time, hardcore developer/designer with low level coding knowledge, you can pick it up and get a website running, configured and editing to your needs in no time.
However, this simplification is greatly abstracted and to really take full advantage of your WordPress website, you need to dive into the core API systems that make it run. One of these core features is called WP_Query(). If you haven't guessed it, that's what we'll be talking about here.
WP_Query() is an important skill to master as this is essentially the system that will reach out to your database and return your content. By default WordPress provides a process called "The Loop", which will take care of this for us, but once you really start customizing your site, you'll find the default loop can only cover certain aspects. That's where WP_Query() comes in, providing us an easy to use system to query our database for the content we need. No need for complex SQL queries like in traditional development.
Throughout this book, we'll walk through the high level view of what WP_Query() is and how it works all the way to the deepest low level intricacies to build complex, secure and performant queries. Part 1 will be the learning zone, starting off by analyizing our options for quering our content. After we understand why we use WP_Query(), we'll start by diving into the WP_Query() arguments and how to use this object. Next, we'll actually start writing our first query by putting our existing knowledge into action. From there we'll start introducing more complex queries like getting posts based on Taxonomies, Post Types, and Meta Data. If you aren't familar with any of the terminology I just mentioned, don't worry, we'll learn more about these as we approach those areas.
As we progress further into Part 1, We'll begin analyizing the query object that is produced by WP_Query() and how WP_Query() can be utilized to create multiple "loops" in one page. Multiple queries are normally necessary for a complex homepage with a magazine style layout which rquires many different post types and taxonomies in one page. After we really start to peak in the expert level of WP_Query(), we're ready to start mastering our craft and learn about securing our queries to ensure we protect our website/database and also how to handle complex queries and make them performant by using caching and other techniques.
Enough of this jibber jabber, let's dive in already!