Page has a parent and $post->post_parent returns 0

I have several pages with a parent. So, $post->post_parent should be different than 0, right?

echo $post->post_parent;

Is returning 0.

Read More

Thing is, this is only happening in one post category. Do I need to declare that a page has a parent elsewhere? I do it from within the edit page form of that page.

Thanks!

Related posts

Leave a Reply

2 comments

  1. Try echoing serialized($post); to make sure you’re looking at the right page(s). It should return the post_parent so the problem may be either in the call you’re making to get $post, or double-check that the set of pages did save with a parent page.

    Easiest way of doing that is call up “All Pages” and they’ll be indented under the appropriate parent if they’re set up correctly (otherwise opening each one and looking).