KIO
Kreative Ideen online
Classes vs. Objects

Classes vs. Objects

Let’s clearly define the difference between classes and objects.
Classes define a set of rules for objects they create.
Objects are created by instantiating a class, which determines the function of the object.

We see this all the time in WordPress with the WP_Query class. In the global variable,”$qp_query is an object of the WP_Query class that WordPress createds based o the current HTTP request.

For example , let’s say that during session created by requesting the URL for avategory therm archive, we create a new QP_Query object to list posts fo the custom post type “product” and store it in a variable called “$products” and the global “$wp_query” are both objects of the WP_Query class.Both have a property called “$posts” that holds the queried posts, but both hold completely different posts. In fact, each post is represented by an object of the WP_Post class – same class but with totally different objects.