WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I hook the wp_list_pages function so that it reads a value of a custom field and displays it instead of displaying the page title?

share|improve this question
Where is your custom field stored? – toscho Feb 18 '12 at 11:48
up vote 2 down vote accepted

A quick Google Search came up with this


Try the following:

function wp_list_pages_filter($output) {
    // modify $output here, it's a string of <li>'s by the looks of source
    return $output;
add_filter('wp_list_pages', 'wp_list_pages_filter');
share|improve this answer
but how to replace the title by a custom field value ? – Mohamed Said Feb 17 '12 at 16:30
Title? Do you mean the Widget Title? That can be set by going to Dashboard -> Appearance -> Widgets and adding a Pages widget. You can customize the title there. – Zack Feb 17 '12 at 16:34
It is NOT an array of pages, it is a string. – mor7ifer Feb 17 '12 at 16:41
Would you please help :) – Mohamed Said Feb 17 '12 at 16:46
@m0r7if3r I see that now. – Zack Feb 17 '12 at 18:08

A Walker Class extension would be necessary in this case:

class My_Custom_Walker extends Walker_page {
function start_el(&$output, $page, $depth, $args, $current_page) {
    if ( $depth )
        $indent = str_repeat("\t", $depth);
        $indent = '';

    extract($args, EXTR_SKIP);
    $output .= $indent . 
            '<li><div>' . get_post_meta($post_id, $key, $single) . '</div></li>';

} // End start_el
} // End Walker Class

Then, when you use your wp_list_pages function, you would call the class:

// Call class:
$My_Walker = new My_Custom_Walker();

$args = array(
    'walker'      => $My_Walker

wp_list_pages( $args );

Documentation on this subject is a bit scarce so let me know if you need more help.

share|improve this answer

You are able to pass in your own custom walker as one of the args, use this to pass in a walker which extends Walker_Page and uses your own custom post title.

share|improve this answer
I'm sorry but I just need some help code :) – Mohamed Said Feb 17 '12 at 16:50
What part of my implementation is not clear enough for you to write code? – mor7ifer Feb 18 '12 at 4:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.