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:
echo "Parent PostID: " . $post->post_parent . "<br>";
This is the same for the wp_get_post_parent_id function.
Help is very much appreciated.
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.)