From the course: PHP for WordPress

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

WP_Query

WP_Query

- Truth be told, the block editor and specifically the query loop block, has made it easier to get more customized data from your WordPress database without the need for code. But, in my experience, it's still pretty limited. When you're ready to create your own templates and get more or different data from the WordPress database, there's really one right way to do it. WP Query. WP Query is a class. A concept you likely haven't been introduced to yet. You can think of a class as a blueprint for objects. An object is a way of grouping variables and functions together. The powerful part of objects is you can have more than one as long as you name them differently. So if you have a person class, you can use it to create two person objects. Joe and Phil. They'll have the same variables and functions available to them, but the information will be different. You can see in this example, Joe is a person object with the name Joe Casabona and the age 39. Where Phil is a person object with the…

Contents