Support » Plugin: Toolset Types » [Plugin: Types – Custom Fields and Custom Post Types Management] $parent_post ??

  • Resolved Cristiano

    (@iclapton)


    Hi friends,

    To get a child post of a custom post type, we can use this function:

    <?php echo $child_post->fields['my_field']; ?>

    What should I do if I want to get the parent post of some child? I tried this and it didnĀ“t work:

    <?php echo $parent_post->fields['my_field']; ?>

    Thanks!

    http://wordpress.org/extend/plugins/types/

Viewing 5 replies - 1 through 5 (of 5 total)
  • I was looking for the same thing and found that

    wpcf_pr_post_get_belongs($post_id, $post_type)

    returns the id of the parent where $post_id is the id of the child post and $post_type is the type of post the parent is

    Thanks for this code iana12 but I’m having problems working out some details with a parent post field.

    I used the above code to find the post ID of the parent post and then I used the following code….
    <?php echo get_post_meta($parent_post,'wpcf-dob', true); ?>

    What I need is the date output from the dob field in the parent post but it’s not displaying correctly. It gives me some numbers but unfortunately they in no way represent my date. Could someone point me in the right direction?

    Plugin Author brucepearson

    (@brucepearson)

    The date is stored as a unix timestamp. You can use the date function to display it how you want.

    `<?php
    $dob = get_post_meta($parent_post,’wpcf-dob’, true);
    echo date(“F j, Y”, $dob);
    ?>

    Thanks Bruce! Worked great!!

    Plugin Author Amir Helzer

    (@amirhelzer)

    Thanks for letting up know. I’ll mark as resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Types – Custom Fields and Custom Post Types Management] $parent_post ??’ is closed to new replies.