Skip to content

colegeissinger/wp_query-cookbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WP_Query Cookbook

Welcome to the WP_Query Cookbook!

The goal of this book is to provide the ultimate crash course for querying posts on WordPress while utilizing best practices. I'll admit, there is plenty of information around the web that covers WP_Query, but this content normally only consists of the basic script to make some thing happen, completely leaving out the what and why and most importantly the security and performance aspect. That's where this book comes in, a central location that will take you from beginner to master in just a handful of chapters.

Download the Companion Plugin!

To really help out with these heavy, data driven code examples, you'll want to download the companion WP_Query Cookbook plugin to ensure you have matching data and items to query against. This little plugin is best suited for a fresh install of WordPress as it will be adding content, post types, post meta and taxonomies to your database. Enabling this plugin on a production site is not recommended! (Plugin will be coming soon!)

Chapter Outline

Why WP_Query

Every master needs a foundation. We'll start off with inspecting what WP_Query is and how it relates to some of the other similar query functions WordPress packs. They all have certain uses, but 9 times out of 10, WP_Query is what you'll want. This understanding is very important in making a professional decision in your code choices.

Getting our Feet Wet

Now that we have some theory and understanding under our belt, we'll start looking at WP_Query more in-depth. We'll do this by comparing WP_Query to the default "Loop" in WordPress, going over the various arguments it can accept and what the default values will provide.

Our First Query

This short little chapter will be where the fun really begins! We'll take all of our knowledge and built a simple query by pulling posts and pages from the database.

Novice Queries

Now things begin to heat up! We'll now venture away from the default options of WP_Query and start writing some custom queries by utilizing taxonomies, post types and meta data.

Expert Queries

At this point you have a pretty solid understanding of how to use WP_Query. In all honesty there is not much to using it, but now we'll look at using it in more complicated scenarios. We'll Learn how to check for post data and create fallbacks if needed. Then we'll look into how to run multiple queries on one page.

Query Master

The final chapter! The part that decifers the experts from the masters is the use and understanding of data validation and building performant queries. We'll learn about some basics on data validation and how we can use it ensure our queries are secure, then we'll dive into how to turn expensive queries into performant queries.

The Final Word

We'll wrap everything up in here!

About

The complete crash course to mastering WP_Query in WordPress.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published