• I’m using the following code to show sibling pages in the sidebar. What I’d love to be able to do is show the featured thumbnail to the left of the page link. Can anyone point me in the right direction? My php expertise is pretty much copy, paste, and modify. Thanks in advance!

    <ul>
    <?php
    global $post;
    $current_page_parent = ( $post->post_parent ? $post->post_parent : $post->ID );
    
    wp_list_pages( array(
         'title_li' => '',
         'child_of' => $current_page_parent,
         'depth' => '1' )
    );
    ?>
    </ul>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter sjbmaine

    (@sjbmaine)

    I’ve discovered code that part way gets what I need to have happen. This code to pull the sibling pages into the sidebar. How do I turn the page title and thumbnail here into links with the permalink embedded?

    I’m so close….

    <?php global $post; //not neccessary if used in the loop
    $parent = $post->post_parent;
    if( $parent ) :
    	$siblings = get_pages( 'child_of=' . $parent . '&parent=' . $parent . '&exclude=' . $post->ID);
    	if( $siblings ) foreach( $siblings as $sibling ) :
    		//start of whatever you need to output//
    		echo $sibling->post_title;
    		echo get_the_post_thumbnail($sibling->ID,'medium');
    		//end of whatever you need to output//
    	endforeach;
    endif; //ends if( $parent ) //
    ?>

    Figured it out!

    <?php global $post; //not neccessary if used in the loop
    $parent = $post->post_parent;
    if( $parent ) :
    $siblings = get_pages( ‘child_of=’ . $parent . ‘&parent=’ . $parent . ‘&exclude=’ . $post->ID);
    if( $siblings ) foreach( $siblings as $sibling ) :
    //start of whatever you need to output//
    $mypermalink = get_permalink($sibling->ID);
    $mysibling = $sibling->post_title;
    echo get_the_post_thumbnail($sibling->ID,’medium’);
    echo “$mysibling” ;
    //end of whatever you need to output//
    endforeach;
    endif; //ends if( $parent ) //
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sibling pages in side bar with featured image’ is closed to new replies.