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

I have a shortcode function that returns:

return '<ul class="list-pages">'. wp_list_pages( $args ) .'</ul>';

Of course it returns:

<ul class="list-pages"></ul>

Instead of:

<ul class="list-pages">

There is almost the same question, but for echo:

Why does this echo values in the wrong order?

And it works perfectly for echo, but I don't know how to use PHP line breaking with "return" (it breaks the whole code).

Thank you!

share|improve this question
up vote 5 down vote accepted

it is b/c wp_list_pages ECHOES by default. so it echoes before your return happens.

wherever you are defining your $args, set

'echo' => FALSE,

see http://codex.wordpress.org/Function_Reference/wp_list_pages

share|improve this answer
brilliant, thanks a lot! :) – Wordpressor Jul 28 '11 at 20:47

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.