I have two results , one with WP_Post
Object and other is stdClass
Object. All contains same data. How do I differentiate them?
Result 1 :-
WP_Post Object
(
[ID] => 952
[post_content] =>
[post_title] =>
[post_excerpt] =>
[post_status] => publish
[comment_status] => open
[ping_status] => open
)
Result 2 : –
stdClass Object
(
[ID] => 952
[post_content] =>
[post_title] =>
[post_excerpt] =>
[post_status] => publish
[comment_status] => open
[ping_status] => open
)
use get_class($object) to get the class name of an object and in your case it would return stdClass and WP_Post for both the respective objects
Refer php.net manual for more detail http://php.net/manual/en/function.get-class.php
You can try to use instanceof
Like this:
I am not sure if it is a valid approach, but I have seen this used in some plugins and projects. So as a possible approach it might work