This is a trivial something that seems to come up staggeringly often when translating design to implementation in word press sites, so I thought I’d post it up here so I don’t have to recreate from scratch next time I need it.
So, you have a long, carefully contrived, SEO-friendly title for your pages (or really just a minimally descriptive one), but you don’t want that to show up in the navigation menus. There are a variety of complex ways to fix this, but one of the easiest is to use code like the following:
< ?php $pages = get_pages("parent=0"); # returns parent pages foreach ($pages as $x_page) { $option = '<li><a href="'.get_page_link($x_page->ID).'">'; $short_title = ""; $short_title = get_post_meta($x_page ->ID, "nav_title", TRUE); if ($short_title == "") $option .= $x_page->post_title; else $option .= $short_title; end; $option .= '</a>'; echo $option; } ?>
This usually ends up in header.php, and is a good patch for the problem. There are a couple of plugins that attempt to work around this by detecting whether or not you’re in the loop (the loop being the name for the main part of post/page printing), but invariably widgets screw this up somehow, and this solution seems to work a bit better for me, especially for a navigation header (hence the name.)
