By default wp_list_pages spits out an unordered list of post titles. To save space in a sidebar menu I´m trying to create a list of page slugs instead of page titles.
I suppose I´ll need to write a custom walker.. I was hoping someone can help me with an easier solution or a code snippet.
I would recommend using
get_pages()
rather thanwp_list_pages()
for this purpose.The
get_pages()
function will return an array of objects of Pages, and you can use the array data to build your own HTML list. e.g.:Then, of course, you just output the function wherever you want to display the list. (Note: this would be a good candidate for a custom Widget. You could even pass the function
get_pages()
arguments as Widget options.)You may need to manipulate the foreach output for styling/etc.