• Hey guys
    Ive triyng and researching a lot, but cant find a solution to this:
    created (using types plugin) a post type named discografia.
    then, another one, which i assigned as child from dicografia, named musica.

    What i want is to display every musica child from a discografia.
    Discografia shows itself like this:

    <?php
    $newsArgs = array( 'post_type' => 'discografia', 'posts_per_page' => 6);
        $newsLoop = new WP_Query( $newsArgs );
       while ( $newsLoop->have_posts() ) : $newsLoop->the_post();              
    
    ?>
    <h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>

    (is a little more full of markup, but nothing unusual – just shoing thumbs and custom fields)

    For testing purposes, i checked if every post shown has its id ok and save it in a variable

    <?php $post_ied = get_the_ID(); 
    
    echo $post_ied;
    ?>

    it worked fine.

    Now, i need to show musicas in every discografia listed above, i used snippet found on https://snipplr.com/view/62428/

    i changed some variable names, so it dont fight with those i created before… lol

    <?php $loope = new WP_Query( array( 'post_type' => 'musica', 'post_parent' => $post->ID, 'posts_per_page' => 30, 'order' => 'ASC' ) ); ?>
    
                                        <?php while ( $loope->have_posts() ) : $loope->the_post(); ?>
    
                                                  <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    
    <?php endwhile; ?>

    And it works. EXCEPT that it shows all musicas for every post from discografia, not only for its parents… got that?

    i mean musica “MUSICA1” apears for both discografia “DISC1” and “DISC2”, but it is child of DISC1 only

    I tried puting post->ID into a variable, but, even thou it work, it appears that ‘post_parent = something’ ist working =/

    anyone?
    Thnx a lot, i make lots of consults here , all the time, really, but this one i couldnt find the awnser…

Viewing 1 replies (of 1 total)
  • Thread Starter romuloctba

    (@romuloctba)

    It seems that ‘post_parent’ => is broken, cause i try with a wrong word like “hakuna” it shows all posts from ‘music’ post type, but then i put the right id like 154 and it simply returns nothing!

    Im getting crazy on this… lol, im in #5 page of google pagination for terms like “post_parent not workin” or “show child post type” and stuff like that
    i pray with all my heart someone could give me a light when i wake up
    lol

Viewing 1 replies (of 1 total)
  • The topic ‘Can't show child from a custom post type in archives’ is closed to new replies.