Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Walker修改wp_列表_页面,使其仅在WordPress的最低级别显示缩略图?_Wordpress_Hierarchy - Fatal编程技术网

如何使用Walker修改wp_列表_页面,使其仅在WordPress的最低级别显示缩略图?

如何使用Walker修改wp_列表_页面,使其仅在WordPress的最低级别显示缩略图?,wordpress,hierarchy,Wordpress,Hierarchy,我在一个作家的网站上工作。页面的结构如下所示: All Books Series Series A Book 1, Book 2, etc. Series B Book 1, Book 2, etc. Stand-alone novels Book 1, Book 2, etc. 每本书都有自己的一页 我可以使用wp_list_页面生成任意级别的链接列表。我需要做的是使用Walker类来定制wp_列表_页面,但是只有

我在一个作家的网站上工作。页面的结构如下所示:

All Books
   Series
     Series A
        Book 1, Book 2, etc.
      Series B
        Book 1, Book 2, etc.
   Stand-alone novels
      Book 1, Book 2, etc.
每本书都有自己的一页

我可以使用wp_list_页面生成任意级别的链接列表。我需要做的是使用Walker类来定制wp_列表_页面,但是只有最低级别的书籍使用特色图片=书籍封面作为链接


我该怎么做?也就是说,我如何只在树的不同部分的最低层(即从树的顶部向下的步数不同)上输入图像

检查页面是否有子项:

class Thumbnail_walker extends Walker_page {
    function start_el(&$output, $page, $depth, $args, $current_page) {
        if ( $depth )
            $indent = str_repeat("\t", $depth);
        else
            $indent = '';

        extract($args, EXTR_SKIP);
        $css_class = array('page_item', 'page-item-'.$page->ID);
        if ( !empty($current_page) ) {
            $_current_page = get_page( $current_page );
            _get_post_ancestors($_current_page);
            if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) )
                $css_class[] = 'current_page_ancestor';
            if ( $page->ID == $current_page )
                $css_class[] = 'current_page_item';
            elseif ( $_current_page && $page->ID == $_current_page->post_parent )
                $css_class[] = 'current_page_parent';
        } elseif ( $page->ID == get_option('page_for_posts') ) {
            $css_class[] = 'current_page_parent';
        }

        $css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );

        $children = get_children( 'post_type=page&numberposts=1&post_parent=' . $page->ID );
        if ( empty($children) ) {
            $link_contents = $link_before . apply_filters( 'the_title', '' ) . $link_after . get_the_post_thumbnail($page->ID, array(72,72));
        }
        else {
            $link_contents = $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_contents .'</a>';

        if ( !empty($show_date) ) {
            if ( 'modified' == $show_date )
                $time = $page->post_modified;
            else
                $time = $page->post_date;

            $output .= " " . mysql2date($date_format, $time);
        }
    }
}