Grandchildren aren't shown by get_pages when using meta tags
-
Hello,
I’m working on a custom page template that will show me every grandchild of a certain page that has a certain meta key and meta value. The thing is I have multiple artist pages and I want to show all the albums of that artist on this page, using that certain meta key and meta value. However, my code is failing me.
My pages are build up as followed:
– Albums (parent page) [page id = 127]
— Albums from 2012 (child page) [page id = 6414]
— Album 1 (grandchild)
— Album 2 (grandchild)
— Album 3 (grandchild)
— etc.
— Albums from 2011 (child page) [page id = 6423]
— Album 4 (grandchild)
— Album 5 (grandchild)
— etc.My code is as followed:
<?php $mypages = get_pages(array( 'child_of' => 127, 'sort_column' => 'post_date', 'sort_order' => 'desc', 'meta_key' => 'artist', 'meta_value' => $post->post_name )); ?> <?php foreach($mypages as $page) { ?> <article class="item switched_images"> <a href="<?php echo get_page_link($page->ID) ?>" alt="<?php echo $page->post_title ?>"><?php echo get_the_post_thumbnail($page->ID, 'thumbnail', array('title' => '', 'class' => 'des')); ?></a> <h3><a href="<?php echo get_page_link($page->ID) ?>" alt="<?php echo $page->post_title ?>"><?php echo $page->post_title ?></a></h3> </article><!--.item .switched_images--> <?php } ?>
The key of this peace of code is that the slug of the artist page is the same meta value I give an album. This way every artist page should get their own albums listed.
When i use ‘child_of’ => 127 in cooperation with the meta_key and meta_value it won’t show me any grandchildren. When I remove the bit where it says meta_key and meta_value, it shows me all of the grandchildren. Are these three conflicting with each other, or is there something I forgot?
Can somebody help me with this?
- The topic ‘Grandchildren aren't shown by get_pages when using meta tags’ is closed to new replies.