【发布时间】:2014-08-07 07:40:27
【问题描述】:
我在 Wordpress 中为 wp_list_pages() 创建了一个自定义 walker。此 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>';
}
}
【问题讨论】: