[Resolved] Show child posts from a certain post type wich is child to another
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 http://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 =/
Thnx a lot, i make lots of consults here , all the time, really, but this one i couldnt find the awnser…
- The topic ‘[Resolved] Show child posts from a certain post type wich is child to another’ is closed to new replies.