Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've made a custom walker to use with wp_list_pages to modify the output to have thumbnails show. The goal is to have a list show up in a page template, which lists all children with their children.

The walker I have below seems to work for getting the thumbnail and page title but doesn't get the url of the page. Do I need to somehow use a getprefixed function instead of just esc_attr?

            class bio_walker extends Walker_Nav_Menu
            {

            function start_el(&$output, $item, $depth, $args)
            {


            $output .= "<li id='menu-item-$item->ID' class='bio-list'>";

            $attributes  = "class='highlight-$item->ID'";

            ! empty( $item->attr_title )
                and $attributes .= ' title="'  . esc_attr( $item->attr_title ) .'"';
            ! empty( $item->target )
                and $attributes .= ' target="' . esc_attr( $item->target     ) .'"';
            ! empty( $item->xfn )
                and $attributes .= ' rel="'    . esc_attr( $item->xfn        ) .'"';
            ! empty( $item->url )
                and $attributes .= ' href="'   . esc_attr( $item->url        ) .'"';


            $pageid = get_post_meta ( $item->ID, '_menu_item_object_id', true);
            $thumbnail = get_the_post_thumbnail( $item->ID, 'bio-thumb', true);


            $title = get_the_title($item->ID);

            $spanclass = "class='span-$item->ID bio-list-span'";

            $item_output = $args->before
                . "<a $attributes>"
                . $thumbnail
                . "<span $spanclass>"
                . $title
                . $pageid
                . "</span>"
                . '</a> ';

            $output .= apply_filters(
                'walker_nav_menu_start_el'
            ,   $item_output
            ,   $item
            ,   $depth
            ,   $args
            );
            }
            }
share|improve this question

1 Answer 1

up vote 1 down vote accepted

figured it out - in case anyone else stumbles upon this with a similar question:

The proper walker to extend is Walker_Page, not Walker_Nav_Menu.

Walker_page is located in /wp-includes/post-template.php (line 978).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.