cqde
cqde

Reputation: 705

WP Displaying Featured Images of all Pages

I've got a bit of a taxonomy working in my WordPress site that deals with products. I've got Pages organized as the product categories and then I created a custom post type for my products to be organized even more.

For the parent page, I want to pull all thumbnails (specifically the Featured Image of the page) from all the children pages.. However, they aren't directly children, but pages in my custom post type.

As of now, I've displayed the child page titles on the parent page using with 'campaign' being my custom post type's name:

<?php 
$args = array(
'post_type'=>'campaign',
'title_li'=> __('')
);
wp_list_pages( $args ); 
?> 

Is there a similar way to pull all featured images of a certain post-type?

Upvotes: 0

Views: 1285

Answers (1)

Ben
Ben

Reputation: 16649

Does this help you?

<?php
$mypages = get_pages('
    child_of='.$post->ID.'
    &parent='.$post->ID.');

if($mypages) {
    echo '<ul>';
    foreach($mypages as $page) { ?>
        <li class="page_item">
            <?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?>
            <a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a>
        </li> <?php
    }
    echo '</ul>';
} ?>

Upvotes: 1

Related Questions