I have created a custom walker for wp_list_pages() in Wordpress. This walker displays the featured images of the pages in question. My problem is that I need to also show the caption of these featured images. At the moment this is just showing the title of the page, I don't know how to get the featured image caption instead.
Here is my walker:
class SlideshowPics_walker extends Walker_page {
function start_el( &$output, $page, $depth, $args, $current_page = 0 ) {
if(has_post_thumbnail($page->ID)){
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'main-featured-thumbnail' );
$link_title = $link_before . '<img src="'.$image[0].'" alt="'.esc_attr( wp_strip_all_tags( apply_filters( 'the_title', $page->post_title, $page->ID ) ) ).'"/><div class="caption">'.apply_filters( 'the_title', $page->post_title, $page->ID ). $link_after.'</div>';
} else
$link_title= $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after;
$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_title . '</a>'
.'</li>';
}
}