Toolset Types
[resolved] [Plugin: Types - Custom Fields and Custom Post Types Management] $parent_post ?? (6 posts)

  1. Cristiano
    Posted 3 years ago #

    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']; ?>



  2. iana12
    Posted 3 years ago #

    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

  3. Matt Barrett (corradomatt)
    Posted 3 years ago #

    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?

  4. brucepearson
    Plugin Author

    Posted 3 years ago #

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

    $dob = get_post_meta($parent_post,'wpcf-dob', true);
    echo date("F j, Y", $dob);

  5. Matt Barrett (corradomatt)
    Posted 3 years ago #

    Thanks Bruce! Worked great!!

  6. Amir Helzer
    Plugin Author

    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Toolset Types
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic