function wp_list_pages($args = '') { global $wpdb; parse_str($args, $r); if (!isset($r['child_of'])) $r['child_of'] = 0; if (!isset($r['depth'])) $r['depth'] = 0; if (!isset($r['optiondates'])) $r['optiondates'] = 0; if (!isset($r['modifieddate'])) $r['modifieddate'] = 0; if (!isset($r['sort_column'])) $r['sort_column'] = 'post_title'; if (!isset($r['sort_order'])) $r['sort_order'] = 'ASC'; $exclusions = ''; if (!empty($r['exclude'])) { $expages = preg_split('/[\s,]+/',$r['exclude']); if (count($expages)) { foreach ($expages as $expage) { $exclusions .= ' AND ID <> ' . intval($expage) . ' '; } } } $option_dates = ''; if(!empty($r['optiondates'])) { if(!empty($r['modifieddate'])) $option_dates = ",UNIX_TIMESTAMP(post_modified) AS ts"; else $option_dates = ",UNIX_TIMESTAMP(post_date) AS ts"; } $post_parent = ''; if($r['child_of']) { $post_parent = ' AND post_parent=' . $r['child_of'] . ' '; } $pages = $wpdb->get_results("SELECT " . "ID, post_title,post_parent " . "$option_dates " . "FROM $wpdb->posts " . "WHERE post_status = 'static' " . "$post_parent" . "$exclusions " . "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']); $page_tree = Array(); foreach($pages as $page) { $page_tree[$page->ID]['title'] = $page->post_title; if(!empty($r['optiondates'])) { $page_tree[$page->ID]['ts'] = $page->ts; } $page_tree[$page->post_parent]['children'][] = $page->ID; } page_level_out($r['child_of'],$page_tree, $r); } function page_level_out($parent, $page_tree, $args, $depth = 0) { if($depth) $indent = join(array_fill(0,$depth,"\t")); foreach($page_tree[$parent]['children'] as $page_id) { $cur_page = $page_tree[$page_id]; $title = $cur_page['title']; echo $indent . '
  • ' . $title . ''; if(isset($cur_page['ts'])) { $format = get_settings('date_format'); if(isset($args['date_format'])) $format = $args['date_format']; echo " " . gmdate($format,$cur_page['ts']); } echo "\n"; if(isset($cur_page['children']) && is_array($cur_page['children'])) { echo "$indent\n"; } echo "$indent
  • \n"; } }