Why does WP_Query have methods that return public properties of the same name
While your example of is_search() is a rather trivial one and harder to justify, it’s generally recommended in OOP styles to use getters and setters for things like this instead of public properties, for a number of reasons. Encapsulation. The behavior of is_search() returns a boolean, but the method by which it determines whether or … Read more