[wp-testers] Page as home and List Pages

Mark Jaquith mark.wordpress at txfx.net
Sat Dec 23 05:14:21 GMT 2006


On Dec 22, 2006, at 8:09 PM, Michael B wrote:

> While testing 2.1, I've noticed that if I Create a Page to be the  
> "home"
> page, and do a simple horizontal navigation such as
> <ul>
>        <li class="<?php if (is_home()) {echo 'page_item  
> current_page_item';
> } ?>"><a href="<?php bloginfo('url'); ?>/">Home</a></li>
>         <?php wp_list_pages('title_li=' ); ?>
> </ul>
>
> Both the  page and a home link show in the nav bar.

There is a filter for wp_list_page() exclusions in WP 2.1 called  
wp_list_pages_excludes.  It passes an array of excluded page IDs (as  
manually passed to the function) and you can modify the array and  
return it.  So you could implement that in the theme's functions.php

(untested example)

> <?php
>
> function yourthemeprefix_remove_home_link($excludes) {
> 	// quick exit if we're not showing a page up front or if the front  
> page is already excluded
> 	if ( 'page' != get_option('show_on_front') || in_array(get_option 
> ('page_on_front'), $excludes) )
> 		return $excludes;
> 	$excludes[] = get_option('page_on_front');
> 	return $excludes;
> }
>
> add_filter('wp_list_pages_excludes',  
> 'yourthemeprefix_remove_home_link');
>
> ?>

The best option, I think, is not to hardcode the "Home" link in the  
theme.  If they want a Home link in their wp_list_pages() output,  
they can use my Page Links To [1] plugin to do that.  That'll work no  
matter what theme they're using, and they'll be able to manually  
place the link (your code forces it to always be first).

What would you think about making that functionality part of core for  
2.2 or beyond?  It seems to be a common problem... people frequently  
want their wp_list_pages() output to have links to non-page WP  
content or non-WP content (like their Flickr page or their site's  
forums).

--
Mark Jaquith
http://markjaquith.com/

Covered Web Services
http://covered.be/




More information about the wp-testers mailing list