WordPress: link_before and link_after don't display in wp_list_pages

Have you ever stumbled across the issue where wp_list_pages isn't spitting out the text you define for link_before and link_after? I came across this some time ago: one minute my lovely pipe bars '|' where there, the next they weren't. It turns out this is due to the EXTREMELY popular All in One SEO Pack plugin (if you're not using this you should be!).

The All in One SEO Pack plugin lets you define menu labels for pages which are used instead of the page titles. It uses a filter to swap these out, and unfortunately when it swaps out the titles it also swaps out whatever text was declared for link_before and link_after. This is particularly annoying as it happens even if you don't supply a custom menu label.

This is only a small bug in the plugin to fix, and I have provided code which will fix it to the plugin author. In the meantime, if you run into this issue there is a simple work around. Please Note: this will prevent AIOSEOP from swapping your page titles for your custom menu labels, so don't do this if you still want to use them!!

In your template, before you use the wp_list_pages function, add the following line of code:
[cc lang="php"]< ?php remove_filter('wp_list_pages','aioseop_list_pages'); ?>[/cc]
Then afterwards add the following:
[cc lang="php"]< ?php add_filter('wp_list_pages','aioseop_list_pages'); ?>[/cc]

This temporarily disables then reenables the filter so your menu is output properly.

So all together you should end up with something like:

[cc lang="php"]

    < ?php remove_filter('wp_list_pages','aioseop_list_pages'); wp_list_pages(array('title_li' => '', 'sort_column' => 'menu_order', 'depth' => 1, 'link_after' => ' / ')); add_filter('wp_list_pages','aioseop_list_pages'); ?>

Hopefully this will stop other folks from going mad wondering why bits of their menu have disappeared!

Please note: I have known this issue to occur in AIOSEOP versions >