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 am creating a shortcode. The shortcode will output a list of pages with the wp_list_pages() function. I am using the ('title_li') parameter and the list headline will be removed, because it is left empty and the "ul tag" will be removed as well, which is not desired.


Now I am trying to wrap it in ul tag again. This is what I am trying but it will return list of pages in "li" with out the "ul tag".

function sitemap_function() {
  $return_string .= "<ul>";
  $return_string .= wp_list_pages('sort_column=menu_order&title_li=');
  $return_string .= "</ul>";

  return $return_string;

function register_shortcodes() {
  add_shortcode('sitemap', 'sitemap_function');

add_action('init', 'register_shortcodes');

Hope someone can help me out here. Thanks in Advance.

share|improve this question
up vote 0 down vote accepted

you need to sert the 'echo' parameter of wp_list_pages() to 0 (zero):

$return_string .= wp_list_pages('sort_column=menu_order&title_li=&echo=0');
share|improve this answer
Works! Great, thanks a lot Michael. – Ingvi Sep 20 '12 at 13:24

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.