{"id":797,"date":"2012-11-03T18:51:59","date_gmt":"2012-11-03T07:51:59","guid":{"rendered":"http:\/\/howden.net.au\/thowden\/?p=797"},"modified":"2012-11-03T18:51:59","modified_gmt":"2012-11-03T07:51:59","slug":"wordpress-wp_list_pages-includes-home-link-for-no-reason","status":"publish","type":"post","link":"https:\/\/howden.net.au\/thowden\/2012\/11\/wordpress-wp_list_pages-includes-home-link-for-no-reason\/","title":{"rendered":"WordPress wp_list_pages includes Home link for no reason"},"content":{"rendered":"<p>Well, it&#8217;s never for &#8216;no reason&#8217; but it can be hard to find.<\/p>\n<p>I have been working with the free download ColorWay theme By <a href=\"http:\/\/www.inkthemes.com\/\">InkThemes.com<\/a> and while I like the theme it was annoying me that when I used the <a href=\"http:\/\/howden.net.au\/thowden\/2012\/04\/wordpress-and-child-page-listing\/\">wp_list_pages function to get a list of child pages <\/a>(which I logged earlier this year), it kept adding the Home page to the list as if it were a child of the page.<\/p>\n<p>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:<\/p>\n<p>[text]<br \/>\nwp-contentthemescolorwayfunctionsinkthemes-functions.php<br \/>\n[\/text]<\/p>\n<p>What I found was that the add_filter was being applied for the specific purpose and was then left as a persistent process.<\/p>\n<p>at around line 46<br \/>\n[php]<br \/>\nwp_list_pages(&#8216;title_li=&amp;show_home=1&amp;sort_column=menu_order&#8217;);<br \/>\n[\/php]<br \/>\nand at around Line 63<br \/>\n[php]<br \/>\nadd_filter(&#8216;wp_list_pages, &#8216;inkthemes_new_nav_menu_items&#8217;);<br \/>\n[\/php]<\/p>\n<p>Line 46 was inside a function which builds the main menu:<\/p>\n<p>[php]<br \/>\nfunction inkthemes_nav_fallback() {<br \/>\n\t?&gt;<br \/>\n    &lt;div id=&quot;menu&quot;&gt;<br \/>\n        &lt;ul class=&quot;ddsmoothmenu&quot;&gt;<br \/>\n            &lt;?php<br \/>\n               wp_list_pages(&#8216;title_li=&amp;show_home=1&amp;sort_column=menu_order&#8217;);<br \/>\n            ?&gt;<br \/>\n        &lt;\/ul&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n    &lt;?php<br \/>\n}<br \/>\n[\/php]<\/p>\n<p>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.<br \/>\n[php]<br \/>\nfunction inkthemes_nav_fallback() {<br \/>\n        \/\/ 20121103 thowden copied from line 63 to place relevant to this function only<br \/>\n        add_filter(&#8216;wp_list_pages&#8217;, &#8216;inkthemes_new_nav_menu_items&#8217;);<br \/>\n\t?&gt;<br \/>\n    &lt;div id=&quot;menu&quot;&gt;<br \/>\n        &lt;ul class=&quot;ddsmoothmenu&quot;&gt;<br \/>\n            &lt;?php<br \/>\n\t\t\twp_list_pages(&#8216;title_li=&amp;show_home=1&amp;sort_column=menu_order&#8217;);<br \/>\n            ?&gt;<br \/>\n        &lt;\/ul&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n    &lt;?php<br \/>\n     \/\/ 20121103 thowden added to reset the standard wp_list_pages function<br \/>\n     remove_filter(&#8216;wp_list_pages&#8217;, &#8216;inkthemes_new_nav_menu_items&#8217;);<br \/>\n}<br \/>\n[\/php]<\/p>\n<p>So now the InkThemes menu will still work but will not perpetuate the wp_list_pages function change.<\/p>\n<p>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.<\/p>\n<p>[php]<br \/>\n\/\/ 20121103 thowden to remove Home from list pages<br \/>\n\/\/add_filter(&#8216;wp_list_pages&#8217;, &#8216;inkthemes_new_nav_menu_items&#8217;);<br \/>\n[\/php]<\/p>\n<p>and all is well with the world again&#8230;  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well, it&#8217;s never for &#8216;no reason&#8217; 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), [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-797","post","type-post","status-publish","format-standard","hentry","category-wordpress-links"],"_links":{"self":[{"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/posts\/797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/comments?post=797"}],"version-history":[{"count":0,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/posts\/797\/revisions"}],"wp:attachment":[{"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/media?parent=797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/categories?post=797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/tags?post=797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}