Ok, ich poste Dir mal eine Lösung, wie ich sie benutzt habe. Da werden innerhalb der list_pages-Funktion auch custom fields ausgegeben. Achtung: Das habe ich für WP 2.3.3 geschrieben. Falls sich die Methoden in neueren WP-Versionen geändert haben, müssten sie theoretisch an diese Änderungen angepasst werden.
Also, folgendes in die functions.php Deines Themes:
/**
* Lists pages according to the given arguments. Displays them for the sidebar
* using custom fields.
*
* @param args The arguments for retrieving the pages. Same as in function
* wp_list_pages.
*/
function my_list_pages($args = '') {
global $wp_query;
$defaults = array(
'depth' => 0, 'show_date' => '',
'date_format' => get_option('date_format'),
'child_of' => 0, 'exclude' => '',
'title_li' => __('Pages'), 'echo' => 1,
'authors' => '', 'sort_column' => 'menu_order, post_title'
);
$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
$pages = get_pages($r);
if (!empty($pages)) {
if ($r['title_li']) {
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
}
if (is_page()) {
$current_page = $wp_query->get_queried_object_id();
}
// generate the actual output
$walker = new My_Walker_Page;
$output .= call_user_func_array(array(&$walker, 'walk'), array($pages, $r['depth'], $current_page, $r));
if ($r['title_li']) {
$output .= '</ul></li>';
}
}
$output = apply_filters('wp_list_pages', $output);
echo $output;
}
Alles anzeigen
Das ist die überschriebene Funktion wp_list_pages. Geändert wurde nur der Klassenaufruf unten von Walker_Page zu My_Walker_Page. In der sidebar.php ersetzt Du dann natürlich wp_list_pages() durch my_list_pages(). Argumente bleiben gleich. Und dann natürlich die neue Klasse, welche die alte Klasse erweitert (einfach darunter in die functions.php):
/**
* Walker implementation, extending the standard page walker to modify the
* output.
*/
class My_Walker_Page extends Walker_Page {
/**
* Outputs a single element of the tree. Overwritten from Walper_Page.
*/
function start_el($output, $page, $depth, $current_page, $args) {
// prepare
if ($depth) {
$indent = str_repeat("\t", $depth);
}
extract($args, EXTR_SKIP);
$css_class = 'page_item page-item-'.$page->ID;
$_current_page = get_page($current_page);
if ($page->ID == $current_page) {
$css_class .= ' current_page_item ';
} else if ($_current_page && $page->ID == $_current_page->post_parent) {
$css_class .= ' current_page_parent';
}
// get the custom field value
$page_headline = get_post_meta($page->ID, 'my_page_headline', true);
// build the output
$output .= $indent . '<li class="' . $css_class . '">';
if (!empty($page_headline)) {
$output .= $indent . "\t" . '<a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '"><img src="' . $page_headline . '" width="201" height="25" alt="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '" title="" /></a><br />';
} else {
$output .= $indent . "\t" . '<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><br />';
}
// add the date and return the output
if (!empty($show_date)) {
if ('modified' == $show_date) {
$time = $page->post_modified;
} else {
$time = $page->post_date;
}
$output .= " " . mysql2date($date_format, $time);
}
return $output;
}
}
Alles anzeigen
In diesem Beispiel wird zu jeder Seite ein Custom Field mit einer Bild-URL ausgelesen (falls vorhanden) und statt des Textes verlinkt. Das müsstest Du jetzt nur zu Deinem gewünschten Output anpassen. Und wie gesagt, keine Garantie, dass es mit WP 2.5 noch so funktioniert. ;-)