Support » Fixing WordPress » Linking to child pages using featured images on parent page

  • Hi all,

    I don’t have a great grasp of PHP, I’m a designer, but I try!

    So, I’m trying to create a page that links to all its child pages using thumbnail images. I’ve got the featured images coming through and working fine, but the links aren’t working! It’s probably pretty obvious to a PHP guy so I thought I’d post my code:

    <!--Child Page Thumbnails Start-->
    <a href="<?php echo  get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php echo $pageChild->post_title; ?>"><?php $subs = new WP_Query( array( 'post_parent' => $post->ID, 'post_type' => 'page', 'meta_key' => '_thumbnail_id' ));
        if( $subs->have_posts() ) : while( $subs->have_posts() ) : $subs->the_post();
        echo get_the_post_thumbnail($post->ID);
        endwhile; endif; wp_reset_postdata(); ?></a>
    <!--Child Page Thumbnails End-->

    I’d link to the page, but it’s behind username and password i’m afraid. Top secret stuff 🙂 Any help would be massively appreciated.

  • The topic ‘Linking to child pages using featured images on parent page’ is closed to new replies.