Inset image thumbnail from page into list

I currently have 10 child pages which each contain one main image and text. I then have the main parent page, which acts

I currently have 10 child pages which each contain one main image and text.

I then have the main parent page, which acts as a 'contents page'.

I currently have this code on the main parent page...

<ul class="treatments-list h3">
    <?php wp_list_pages('title_li=&child_of='.$post->ID=15); ?>
</ul>

This gets all the titles for these child pages and lists them, however, I would like to add an image thumbnail at the start of each of these lists, how can I do this?

Thanks in advance.

I currently have 10 child pages which each contain one main image and text.

I then have the main parent page, which acts as a 'contents page'.

I currently have this code on the main parent page...

<ul class="treatments-list h3">
    <?php wp_list_pages('title_li=&child_of='.$post->ID=15); ?>
</ul>

This gets all the titles for these child pages and lists them, however, I would like to add an image thumbnail at the start of each of these lists, how can I do this?

Thanks in advance.

Share Improve this question asked Dec 24, 2012 at 15:27 AdamAdam 6555 gold badges11 silver badges19 bronze badges 2
  • Is the image in the post body? – s_ha_dum Commented Dec 24, 2012 at 15:39
  • yes it is in the body – Adam Commented Dec 24, 2012 at 18:09
Add a comment  | 

1 Answer 1

Reset to default 1

You can use get_pages to do that:

<?php $pages = get_pages(array('child_of' => get_the_ID())); ?> 
<ul class="treatments-list h3">
    <?php foreach ($pages as $page): ?>
        <li>
            <?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?>
            <h2>
                <a href="<?php echo get_permalink($page->ID); ?>" title="<?php echo esc_attr($page->post_title);?>">
                    <?php echo $page->post_title; ?>
                </a>
            </h2>
        </li>
    <?php endforeach; ?>
</ul>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745300170a4621388.html

相关推荐

  • Inset image thumbnail from page into list

    I currently have 10 child pages which each contain one main image and text. I then have the main parent page, which acts

    14小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信