navigation - WordPress Page Walker class descendants of parent with thumbnail and custom classes -
please, help!
i'm @ wits end , have finish tomorrow, really appreciate adjusting page walker class. (please!)
the ultimate goal display list in format:
animals //not shown + cats - dogs - bulldogs - boxers - poodles + horses + sheep
depth requirement(s)
on cats, dogs, horses, sheep pages, (animals) bulldogs, boxers, poodles shouldn't display.
however, on dogs page, bulldogs, boxers, poodles in addition cats, horses , sheep page should display.
markup requirements
i need following markup in final output:
<ul class="list"> <li class="list__items"><a href="#link">cats</li> <li class="list__items"><a href="#link">dogs</a> <ul class="sub-tier__list"> <li class="sub-tier__group"><a href="#link">bulldogs</a></li> <li class="sub-tier__group"><a href="#link">boxers</a></li> <li class="sub-tier__group"><a href="#link">poodles</a></li> </ul> </li> </ul>
there's other divs, headings, etc. inside sub-tier__group wanted keep clean presentation purposes.
my current page walker class:
class page_list_with_thumbnail extends walker_page { function start_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "\n$indent<ul>\n"; } function start_el(&$output, $page, $depth, $args, $current_page) { if ( $depth ) $indent = str_repeat("\t", $depth); else $indent = ''; extract($args, extr_skip); $class_attr = ''; if ( !empty($current_page) ) { $_current_page = get_page( $current_page ); if ( (isset($_current_page->ancestors) && in_array($page->id, (array) $_current_page->ancestors)) || ( $page->id == $current_page ) || ( $_current_page && $page->id == $_current_page->post_parent ) ) { $class_attr = 'sel'; } } elseif ( (is_single() || is_archive()) && ($page->id == get_option('page_for_posts')) ) { $class_attr = 'sel'; } if ( $class_attr != '' ) { $class_attr = ' class="' . $class_attr . '"'; $link_before .= '<strong>'; $link_after = '</strong>' . $link_after; } // thumbnail $page_thumbnail = get_the_post_thumbnail( $page->id ); $output .= $indent . '<li' . $class_attr . '><a href="' . get_page_link($page->id) . '"' . $class_attr . '">' . $page_thumbnail . $link_before . apply_filters( 'the_title', $page->post_title, $page->id ) . $link_after . '</a>'; } }
my current template markup:
<?php $walker = new page_list_with_thumbnail(); if($post->post_parent) $children = wp_list_pages( array ( 'title_li' => '', 'child_of' => $post->post_parent, 'echo' => '0', 'depth' => '0', 'walker' => $walker ) ); else $children = wp_list_pages("title_li=&child_of=".$post->id."&echo=0"); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>
bonus: thumbnail output
currently, there's get_the_post_thumbnail( $page->id );
measure, if can spit out alt, title attributes individual headings icing on nightmare cake.
i've done best piece things found on here (and 4 million other google searches) i'm hoping it's easy fix beautiful wp ninjas out there.
thank much!
Comments
Post a Comment