开发者

WP Displaying Featured Images of all Pages

开发者 https://www.devze.com 2023-02-16 19:26 出处:网络
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 开发者_StackOverflowcreated a custom post type for m

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 开发者_StackOverflowcreated 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?


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>';
} ?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号