Well, it’s never for ‘no reason’ but it can be hard to find.
I have been working with the free download ColorWay theme By InkThemes.com and while I like the theme it was annoying me that when I used the wp_list_pages function to get a list of child pages (which I logged earlier this year), it kept adding the Home page to the list as if it were a child of the page.
As it turns out after much tracking of the source of the issue, I find that the Colorway theme includes an add_filter function to insert the Home link at the top of the wp_list_pages function to build the main menu. I tracked this down to this file:
[text]
wp-contentthemescolorwayfunctionsinkthemes-functions.php
[/text]
What I found was that the add_filter was being applied for the specific purpose and was then left as a persistent process.
at around line 46
[php]
wp_list_pages(‘title_li=&show_home=1&sort_column=menu_order’);
[/php]
and at around Line 63
[php]
add_filter(‘wp_list_pages, ‘inkthemes_new_nav_menu_items’);
[/php]
Line 46 was inside a function which builds the main menu:
[php]
function inkthemes_nav_fallback() {
?>
<div id="menu">
<ul class="ddsmoothmenu">
<?php
wp_list_pages(‘title_li=&show_home=1&sort_column=menu_order’);
?>
</ul>
</div>
<?php
}
[/php]
Which I modified to basically place the add_filter as a part of this function only and added a remove_filter at the end to put it back to normal.
[php]
function inkthemes_nav_fallback() {
// 20121103 thowden copied from line 63 to place relevant to this function only
add_filter(‘wp_list_pages’, ‘inkthemes_new_nav_menu_items’);
?>
<div id="menu">
<ul class="ddsmoothmenu">
<?php
wp_list_pages(‘title_li=&show_home=1&sort_column=menu_order’);
?>
</ul>
</div>
<?php
// 20121103 thowden added to reset the standard wp_list_pages function
remove_filter(‘wp_list_pages’, ‘inkthemes_new_nav_menu_items’);
}
[/php]
So now the InkThemes menu will still work but will not perpetuate the wp_list_pages function change.
But, the body of the page list is still a problem and that is because line 63 as shown above is NOT in a function and is always applied. So the simple solution is to delete it, or comment it out of the code.
[php]
// 20121103 thowden to remove Home from list pages
//add_filter(‘wp_list_pages’, ‘inkthemes_new_nav_menu_items’);
[/php]
and all is well with the world again…