In WordPress, post_parent returns 0

I just started customizing my own WordPress website. I have some experience in PHP programming, but I can’t get this one to work.

With the wp-types plugin I created a parent-children relationship. When I request the ID of the parent, it always returns zero:

Read More
echo "Parent PostID: " . $post->post_parent . "<br>";

This is the same for the wp_get_post_parent_id function.

Help is very much appreciated.

Related posts

Leave a Reply

1 comment

  1. The post_parent is a WordPress core feature, and isn’t related to the parent-child relationships set up in the Types plugin. (The relationship in Types is stored in custom fields on the posts.)

    A post on the Types support forum suggests suggests this method for finding the parent of a post in Types:

    $parent_id = wpcf_pr_post_get_belongs(get_the_ID(), 'parent-type-slug');
    if (!empty($parent_id)) {
      $parent = get_post($parent_id);
    }
    

    (It’s slightly easier to go the other way around, as there’s a types_child_posts method for returning the Types children of a post.)