WordPress.org

Ready to get started?Download WordPress

Forums

Siblings list with thumbnails (2 posts)

  1. michaelhastrich
    Member
    Posted 2 years ago #

    Hi,

    Currently I'm using this code:

    <?php
    	if($post->post_parent)
    	$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    	else
    	$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    	        if ($children) { ?>
    		<ul>
    		<?php echo $children; ?>
    		</ul>
    	       <?php } ?>

    to get a list of child pages when on a child page.
    This is now output as an ul with li-items. What I would like is to get the thumbnails for the li-items. My guts tells me I need to do some foreach-loop on the list items, but I've got no idea how to do that.
    Hope somebody can help me with this.

    Cheers
    Michael

  2. Nic-O
    Member
    Posted 2 years ago #

    You can list sibling thumbnails like this:

    <?php 
    
    $child_pages = $wpdb->get_results("SELECT *    FROM $wpdb->posts WHERE post_parent = ".$post->post_parent."    AND post_type = 'page' ORDER BY menu_order", 'OBJECT');
    
    if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
    
    <div class="overview-image">
    <a href="<?php echo  get_permalink($pageChild->ID); ?>" title="<?php echo $pageChild->post_title; ?>"></a>
    <h2><?php echo $pageChild->post_title; ?></h2>
    <?php echo get_the_post_thumbnail($pageChild->ID, 'overview-thumb'); ?>
    </div>
    <?php endforeach; endif; ?>

    Cheers!
    -Nic

Topic Closed

This topic has been closed to new replies.

About this Topic