[wp-hackers] problem with $post->post_parent

Brian Fidler fidler.brian at gmail.com
Tue Mar 30 06:19:54 UTC 2010


got it. Thanks everyone!

brian


 [image: brian fidler interactive] <http://www.brianfidler.com>
email: interactive at brianfidler.com
phone: 602.758.4733
[image: View Brian Fidler's profile on
LinkedIn]<http://www.linkedin.com/in/brianfidler>


On Mon, Mar 29, 2010 at 6:56 PM, Will Anderson <will at itsananderson.com>wrote:

> Inside the checkPostID function, you're using $post, but you never declare
> it as a global, so it will be null. Try this and see what happens
>
> function checkPostID() {
>   global $wp_query, $post; // global $post as well
>    $thePostID = $wp_query->post->ID;
>   $myParent = $post->post_parent;
>   echo "i am post ". $thePostID . " and my parent is " . $myParent;
> }
>
> If this code is being executed before the $post variable is populated, it
> will still not contain the post parent.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list