If you’ve tried to use wp_link_pages outside your sidebar (for example, at the end of your Page content, to list child Pages), you’ve probably noticed that it creates it’s own set of LI tags before the title….which is non-standard code for a standalone list.
This manifests itself in an unexpected (and probably unwanted) bullet before your list title (or a lone bullet alongside your first Page link, if you used the title_li=0 argument), and often by making the “bullet” for all subsequent Page links appear as something other than a bullet (in mine, it looks like this: >> ) because it’s reading them as sub-nested list items. What a mess!
Maybe this is convenient if you only use wp_list_pages inside of an existing ordered or unordered list, but I generally don’t….so I have been fighting this strange bullet problem for quite some time.
It may be possible for you to style away this problem by adding CSS classes for .pagenav and .page_item, but if that’s not working for you, then you might want to edit the function itself. Editing the core of WordPress isn’t generally recommended, but sometimes it becomes necessary.
Here are instructions for WordPress 2.1.3. Other versions are probably similar. Don’t forget to make a back up before you do this!!!
You’ll be changing this file:
/wp-includes/post_functions.php.
Locate “function wp_list_pages” (line 265 in my 2.1.3)
Look for the “if” statement and remove the opening and closing LI tags in the two lines that begin with ?output= (one of them includes class=pagenav), so it reads as follows:
if ( !empty($pages) ) {
if ( $r['title_li'] )
$output .= '' . $r['title_li'] . '<ul>';
global $wp_query;
if ( is_page() )
$current_page = $wp_query->get_queried_object_id();
$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
if ( $r['title_li'] )
$output .= '</ul>';
}
When looking at the whole function, you’ll see you can also remove the page_item class for the inner nested LIs if you want, but you can also just not define that class in CSS and it won’t do anything.
Leave a Reply
- Chocolate Recipies (1)
- Code Snippets (4)
- How Tos (5)
- Internet (1)
- Plugins (2)
- Security (2)
- Tools (1)
- Tutorials (2)
- Webmaster (1)
- WordPress (7)


