Advertisement
Guest User

Untitled

a guest
Dec 24th, 2011
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. class My_Page_Walker extends Walker_Page {
  2.  
  3. function start_el(&$output, $page, $depth, $args, $current_page) {
  4. if ( $depth )
  5. $indent = str_repeat("\t", $depth);
  6. else
  7. $indent = '';
  8.  
  9. extract($args, EXTR_SKIP);
  10. $css_class = array('page_item', 'page-item-'.$page->ID);
  11. if ( !empty($current_page) ) {
  12. $_current_page = get_page( $current_page );
  13. _get_post_ancestors($_current_page);
  14. if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) )
  15. $css_class[] = 'current_page_ancestor';
  16. if ( $page->ID == $current_page )
  17. $css_class[] = 'current_page_item';
  18. elseif ( $_current_page && $page->ID == $_current_page->post_parent )
  19. $css_class[] = 'current_page_parent';
  20. } elseif ( $page->ID == get_option('page_for_posts') ) {
  21. $css_class[] = 'current_page_parent';
  22. }
  23.  
  24. $css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
  25.  
  26. $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>';
  27. if($page->ID == 39){ // put the portfolio archive link behind this Page
  28. global $wp_query;
  29.  
  30. if(isset($wp_query->query_vars['post_type'])&& $wp_query->query_vars['post_type']=='portfolio'){
  31. if ( $wp_query->is_archive )
  32. $css_class = 'page_item current_page_item';
  33. else
  34. $css_class = 'page_item';
  35. }
  36. $output .= '</li><li class="' . $css_class . '"><a href="/portfolio">' . $link_before . 'Portfolio' . $link_after . '</a>';
  37.  
  38. }
  39.  
  40.  
  41. if ( !empty($show_date) ) {
  42. if ( 'modified' == $show_date )
  43. $time = $page->post_modified;
  44. else
  45. $time = $page->post_date;
  46.  
  47. $output .= " " . mysql2date($date_format, $time);
  48. }
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement