• Resolved jigowatt

    (@jigowatt)


    Hi,

    I’m using the following code to display a pages subpages;

    <?php
    					// If CHILD_OF is not NULL, then this page has a parent
    					// Therefore, list siblings i.e. subpages of this page's parent
    					if($post->post_parent){
    						wp_list_pages('title_li=&include='.$post->post_parent);
    						wp_list_pages('title_li=&child_of='.$post->post_parent);
    						}
    					// If CHILD_OF is zero, this is a top level page, so list subpages only.
    					else{
    						wp_list_pages('title_li=&include='.$post->ID);
    						wp_list_pages('title_li=&child_of='.$post->ID);
    						}
    					?>
    					</ul>

    And it’s working perfectly. However, these subpages are galleries and I would love to display the page thumbnail in the outputted list so that the user catches a glimpse of the gallery instead of just seeing a text link.

    Surely there’s any easy way to do this!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jigowatt

    (@jigowatt)

    Sorted it myself using the following code:

    <ul class="subpages">
    <span style="display:none;"><?php the_ID(); ?></span>
    <?php $parent = $post->ID; ?>
    <?php
    query_posts('posts_per_page=15&post_type=page&post_parent='.$parent);
     while (have_posts()) : the_post();
    ?>
    
    <?php $image_thumb = get_post_meta($post->ID, 'image-thumb', true); ?>
    <li><?php the_post_thumbnail(); ?>
    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4></li>
    
    <?php endwhile; ?>
    </ul>

    Fantastic – thanks for the post – works perfectly!

    Do you have a link to show what this looks like?

    Also, where do you place this code? (what directory/file)?

    I’m trying to do the same thing- have a parent page with thumbnail links to the child pages/posts.

    Thanks!

    This lists out the subpages, but I can’t get the thumbnails to show up.

    I’m getting this error:
    Fatal error: Call to undefined function the_post_thumbnail()

    Could you show us what you’re entire template code looks like?

    [email protected]

    (@postasbjornpettersencom)

    If you put the code inside the_loop it will output the entire page, but if you put this code outside the loop, this is most likely after / below the last <?php endif; ?> this will create only a list of subpages with thumbnail.

    on my customers page i did it like this:

    <?php endwhile; else : ?>
    <?php endif; ?>
    
    <ul class="subpages">
    <span style="display:none;"><?php the_ID(); ?></span>
    <?php $parent = $post->ID; ?>
    <?php
    query_posts('posts_per_page=15&post_type=page&post_parent='.$parent);
     while (have_posts()) : the_post();
    ?>
    
    <?php $image_thumb = get_post_meta($post->ID, 'image-thumb', true); ?>
    <li><?php the_post_thumbnail('single-blog-thumbnail'); ?>
    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4></li>
    
    <?php endwhile; ?>
    </ul>

    I hope this is understandable…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Listing subpages with their thumbnails’ is closed to new replies.