Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

http://codex.wordpress.org/Function_Reference/wp_list_pages#Hiding_or_Changing_the_List_Heading

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

1 Answer 1

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 Jónasson Sep 20 '12 at 13:24

Your Answer

 
discard

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.