View Full Version : Wordpress Navigation Renaming
TR123
09-07-2008, 06:36 PM
Hi
I am currently putting together a website using wordpress 2.6.1 and at the top of the site want to have a page navigation using wp-list-pages
<?php wp_list_pages('title_li=&depth=1'); ?>
The problem is that this uses the titles from my pages and I want these to be different from the navigation. For example - to have a link which perhaps says "About" in the top navigation but the title on that page would perhaps be Welcome to our Website. I know I could just handcode it with HTML but I would like to be able to easily add more pages and choose a link title.
Does any one know if this is possible please?
Thank you
sarahG
09-08-2008, 07:48 AM
When you say title do you mean the content output between the <title></title> tags or the page header?
For the title, then install either the SEO Title tag plugin or the All in One SEO pack plugin. This will allow you to set a title unique from the page header/label. If you intend to use pages on your site, then either of these is highly recommended, however the latter is probably easy to install and gives you more information options.
If it's the page header then in the past I've simply hard coded it in. So the menu label for the page goes into the page title box on the Write Page, and then I've usually used a h2 at the top of the content with the page header in. I'd imagine there's a plugin to allow you to specify a menu label for the page, it wouldn't be hard to create one. Just need to search through the plugin directory at WordPress.org.
TR123
09-08-2008, 08:04 AM
Thanks for trying to help me.
What I mean is that on a page I (when writing a page as as a user would) the title space I would like to have a different heading ie. Welcome to this website. but in the menu navigation I would like the word "about". When I use wp-list pages it automatically puts "Welcome to this website" in the menu navigation.
I have looked in the plugins but will have another look
Thanks
mintblogger
09-08-2008, 09:04 AM
Use the pageMash plugin for easy page management in Wordpress.
TR123
09-08-2008, 09:15 AM
Thanks for the suggestion, but Page mash still doesn't seem allow me to change what is shown in the navigation compared to the page heading
sarahG
09-08-2008, 09:39 AM
You want to have a different page heading to the menu label in the navigation? ie. put your heading in the page title box on the Write Page, and change your menu label. Without a plugin you won't be able to do this, unless you choose to hard code your menu, which isn't the best solution.
The suggestion I've given does the same job, just in different way to the way you're looking for. You don't mess with the navigation and you set the menu label in the page title box as usual. There you would put 'About'. Then in the content box you'd have it as
<h2>Welcome to this website</h2>
Content goes here
And in your page template you look for the line
<h2><?php the_title() ?></h2>
and remove it, as you're putting this out in your content instead.
As I said, it's the not most ideal solution, and a plugin wouldn't be hard to create to give you the control in the admin, but as WP is primarily for blogging and the main focus is still on that (despite it being perfectly powerful as a CMS) then most of the plugins are focused on blogging, not Pages. I'd offer to write the plugin for you if you couldn't find one, but I don't have the time at present unfortunately.
TR123
09-08-2008, 09:52 AM
Hi Sarah
Thanks for the suggestion. I see what you mean the normal heading box would end up being the nav word. The trouble is I think my client may end up editing the site themselves and think they will get in a mess with this, so I may have to hand code.
sarahG
09-08-2008, 02:44 PM
If you don't intend for your client to add more pages, then hand coding will be suitable enough for now. If I get a chance to sort a plugin out I'll leave a reply here for you :)
TR123
09-08-2008, 02:51 PM
Thanks for your help Sarah
TR123
09-12-2008, 04:01 PM
I decided I would hand code the links with html, but I have a problem. I want the current selected page navigation to be highlighted and I am not sure how to do that. I have a red navigation bar at the top and when the site is on home I want the block behind the home text to be red etc etc. I know how to do this with a static site with CSS but not a dynamic one.
Can anybody help please?
Thanks
sarahG
09-12-2008, 07:17 PM
This is the downside to handcoding links. You'll need to use some PHP to determine which page the user is on and then set the class on that item. To put it simply you need to compare the URL with the page link and see if they match ie.
if ($_SERVER['PHP_SELF'] == "/about/")
However to save retyping things over and over, a simply array and loop will cut your typing down eg.
$pgarray = array("/about/" => "About Us", "/contact/" => "Contact Us", "/page3/" => "Page 3 Label", "/page4/" => "Page 4 Label");
$currpg = "current_page_item";
echo "<ul>";
foreach ($pgarray AS $pageurl => $pglabel) :
echo "<li";
if ($pageurl == $_SERVER['PHP_SELF']) echo ' class="'.$currpg.'"';
echo '><a href="'.$pageurl.'">'.$pglabel.'</a></li>';
endforeach;
echo "</ul>";
Then all you need to do is change the array to suit your page paths relative from the domain, and the labels. You've got key => value where key is the path and value is the menu label. And set your class name for the highlighted class.
However, I'll possibly have the time this weekend to get the plugin done for you if it's as easy as I think it is.
TR123
09-13-2008, 08:38 AM
Thanks for helping Sarah, this is all a bit over my head, I know some HTML but not PHP, so if you do have time to write the plugin that would be great.
I would be happy to pay for the plugin (I notice you are creating some commercial plugins on your site) or make a donation.
sarahG
09-27-2008, 03:19 PM
For anyone interested in the discussion in this thread and would like a copy of the plugin that can now achieve this, I've upgraded and released the plugin on my blog at http://www.stuffbysarah.net/blog/wordpress-plugins/page-menu-editor/
Hopefully it'll prove of use to someone :)
TR123
09-27-2008, 03:41 PM
This is fantastic, thanks Sarah, just tested it on my local site.
Thanks again
sarahG
09-27-2008, 04:22 PM
You're welcome, although I did send you a PM 2 weeks ago when I actually made the changes? I just got round to putting up a page and post on my site for it. So you may want to check your private messages on the forum ;)
TR123
09-27-2008, 04:33 PM
My apologies, I didn't notice that, if I got an email alert it must have got mixed up with my junkmail. Have PM'd you back now.
sarahG
09-27-2008, 08:38 PM
No problem :) Glad the plugin does what you need it to :)
vBulletin® v3.8.3, Copyright ©2000-2012, Jelsoft Enterprises Ltd.