Because you’re using a namespace in this class, you need to add a \
in front of the WP_Query call to tell PHP that it’s in the global namespace and not the namespace of this class.
Try this: $query = new \WP_Query($args);
Because you’re using a namespace in this class, you need to add a \
in front of the WP_Query call to tell PHP that it’s in the global namespace and not the namespace of this class.
Try this: $query = new \WP_Query($args);