WordPress.org

Ready to get started?Download WordPress

Forums

Show ancestor of a Custom Post Type (1 post)

  1. romuloctba
    Member
    Posted 2 years ago #

    Hi guys :)
    Well, the thing is, i have a custom post type named DISCOGRAFIA wich is a parent of MUSICA.
    Well, in single-musica.php i have the content shown up, but i need to get the thumbnail and some custom fields from its parent on DISCOGRAFIA
    eq: post type musica ID 222 is child of discografia id 20.
    When showing musica 222 content, i want to retrieve discografia 20's thumbnail.

    I tried ´`$parents = get_ancestors($post->ID, 'musica');
    echo $parents;
    print_r($parents);`´
    it prints an empty array

    i tried
    ´`echo $post->post_parent;
    $argss = array(
    'p' => $post->post_parent
    );
    $parent = new WP_Query( $argss );

    while( $parent->have_posts() ) : $parent->the_post();
    echo $post->ID;

    echo get_the_post_thumbnail( $post->ID, array(100,100) );
    endwhile;`´
    all empty again...

    well, im using "types plugin" to manage custom post types and fields. it has some documentation with custom functions, but none for what i want.

    =) hope someone can help me

Topic Closed

This topic has been closed to new replies.

About this Topic