Alright folks I found the answer. You have to override the Walker class. you can find this in classes.php
class Walker_Webdistortion extends Walker {
var $tree_type = 'page';
var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class='subpage'>\n";
}
function end_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}
function start_el(&$output, $page, $depth, $current_page, $args) {
if ( $depth )
$indent = str_repeat("\t", $depth);
else
$indent = '';
extract($args, EXTR_SKIP);
$css_class = 'page_item page-item-'.$page->ID;
if ( !empty($current_page) ) {
$_current_page = get_page( $current_page );
if ( 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';
}
//get custom field toplevel=1 then dont link
$custom_fields = get_post_custom($page->ID);
$my_custom_field = $custom_fields['toplevel'];
if($my_custom_field[0]==1){
$output .= '<div>'. attribute_escape(apply_filters('the_title', $page->post_title)) .'</div>';
}else{
$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '</a>';
}
if ( !empty($show_date) ) {
if ( 'modified' == $show_date )
$time = $page->post_modified;
else
$time = $page->post_date;
$output .= " " . mysql2date($date_format, $time);
}
}
function end_el(&$output, $page, $depth) {
$output .= "</li>\n";
}
}
Then create a copy of the wp_list_pages function. And wack that into your page.
<?php
function my_wp_list_pages($args = '') {
$defaults = array(
'depth' => 0, 'show_date' => '',
'date_format' => get_option('date_format'),
'child_of' => 0, 'exclude' => '',
'title_li' => '',
'echo' => 1,
'authors' => '', 'sort_column' => 'menu_order, post_title',
'link_before' => '', 'link_after' => ''
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$output = '';
$current_page = 0;
// sanitize, mostly to keep spaces out
$r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);
// Allow plugins to filter an array of excluded pages
$r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
// Query pages.
$r['hierarchical'] = 1;
$pages = get_pages($r);
if ( !empty($pages) ) {
if ( $r['title_li'] )
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
global $wp_query;
if ( is_page() || $wp_query->is_posts_page )
$current_page = $wp_query->get_queried_object_id();
$output .= walk_page_webdistortion($pages, $r['depth'], $current_page, $r);
if ( $r['title_li'] )
$output .= '</ul></li>';
}
//$output = apply_filters('wp_list_pages', $output);
if ( $r['echo'] )
echo $output;
else
return $output;
}
echo(my_wp_list_pages());
?>
Notice $output .= walk_page_webdistortion
Finally tie up your class. In post_template.
function walk_page_webdistortion(){
$walker = new Walker_Webdistortion;
$args = func_get_args();
return call_user_func_array(array(&$walker, 'walk'), $args);
}
You’ll also need to create custom fields for each page which is a pseduopage. toplevel=1 is the variable I checked for in the custom Walker class.
disclaimer. I’m not a PHP coder, so this stuff was relatively alien to me. There is probably a much tidier cleaner way of doing this, but please WP developers lets get the html out of the codebase, or if it must go into it, get it configurable for each function.