Custom Title Attributes
Latest Version: 1.4
Works on: Version 1.5 - 2.5.1
Last Update: 8th May 2008
Custom Page Link Title Attributes allows you to customise the title attribute of any Page link that's being displayed with the Template Tag wp_list_pages(). At present, by default WordPress gives the title attribute of any page link the same text as the anchor text. Why?! There is no point repeating the same text, it's a complete waste of time in my opinion. You should only use a title attribute on a link if you need to expand on the already given anchor text e.g. If the anchor text is 'Home' then you could have the title attribute as 'Return to our Front Page'.
This plugin allows you to add a title attribute for any page you want to, and if you don't then no title attribute will be set. It's mainly been written for sites using WordPress as a CMS however can still be useful to anyone who has one or more pages on their site that are displayed using the wp_list_pages() tag.
For an example, hover your mouse over my pages on the right, 'Learn PHP' should display a tool tip of 'Reference Guide to PHP Tutorials on StuffBySarah'.
Instructions
- Download the Plugin and unzip it.
- Upload it to your plugins directory and activate it via the Plugins section.
- Go into Manage - Pages and edit an existing page OR go to Write - Page. Below the content area you'll see a new box 'Custom Page Link Title Attribute (optional)' See Figure 1.
- Fill this out with the text you require and Save/Publish the page.
- Return to the front end of your site and if you now hover over the link the custom title attribute should appear. See Figure 2.
- Figure 1: Page Link Title Attribute Form Box

- Figure 2: Title Attribute Showing on Link Hover

It's a pretty simple plugin and at present there are no options as I can't really think of any to offer! Any requests please leave them in the comments below and if I can I'll add them in. Any problems also leave them below. This has been tested on the latest versions of WordPress with no problem.
Updates
- 08/05/2008: Upgraded the markup for the admin box in the Add/Edit Page, also fixed it so it doesn't appear in the Add/Edit Post page.
- 09/11/2007: Fixed my original method and reduced the code by 25%.
- 07/11/2007: The plugin wasn't installing correctly if the file wasn't in the plugins root directory so I've updated the code to check it's installed when in use. Also fixed a glitch for when a post and a page has the same slug.
- 06/11/2007: Seems my patterns weren't matching so I've reverted to an older method that does work but involves more code. I'll try and get my more efficient method working in the meantime!


23 Responses to “Custom Title Attributes”
The pages I have currently are pretty much self-explanitory but I have a few plans for adding more that this will be handy for. Thanks for taking the time to code it
By Bob! on Nov 5, 2007
Thing is, this plugin removes the title attribute (unless you set a custom on) for each page. Afterall, what's the point of repeating the anchor text in the title attribute? I'll only set custom ones if they need it, otherwise I'd rather have no title attribute at all
By Sarah on Nov 5, 2007
Cool, I will check it out.
By Ben Partch on Nov 5, 2007
Cheers Ben. Let me know if you stumble across any problems (shouldn't do) or have any additional ideas, as I couldn't think of any
By Sarah on Nov 5, 2007
Seems my pattern matching didn't want to work on a couple of sites so I've changed the code to one I know works. Back to the books to get the better idea/method working!
By Sarah on Nov 6, 2007
Great plugins… seeing more of codes/wordpress than AIS… now I got why you changed the blog url
By Jalaj on Nov 13, 2007
Jalaj, I still have both blogs. You're just on the techie one
By Sarah on Nov 13, 2007
Seems like I followed "Pattern matching with PHP" link on your AIS blog to reach here… Not wrong if someone says "you learn by your mistakes…" as I will learn more of wordpress and PHP following a mistaken click… I am feeling like Columbus… great to discover this blog… don't know how I missed it earlier.
By Jalaj on Nov 13, 2007
Maybe I need a bigger header to denote where people are? Still, glad you're liking both sites. The front page of the domain links to and displays from both
By Sarah on Nov 13, 2007
Upgraded this plugin to
a: Not display on the Add/Edit Post page
b: Fit in with the new WordPress 2.5 design
By Sarah on May 9, 2008
This is just what I was looking for.
However, I also use the wswwpx_fold_page_list() plug-in for my menu.
I've tried editing your plug-in, replacing "wp_list_pages" with "wswwpx_fold_page_list", but can't get it to work.
Any ideas?
PS: I'm not a coder so I'm probably missing something simple!
By Chris Birchall on May 18, 2008
Hi Chris,
The plugin uses a built in 'hook' to grab the page list and alter it. It probably won't work on a plugin as the plugin wouldn't be known within the core WordPress files. Your best option is to perhaps contact the plugin author and ask them if it's possible to get them to add the title attribute option in. Point them to this page and tell them to grab the admin code from my plugin if they want
If you get no joy let me know and I'll take a look at the plugin and see if I can amend it myself for you.
By Sarah on May 19, 2008
Hi Sarah,
Is it possible to modify the list pages code so
that you can choose the text used to create the links?
For example, a page title might be "The Future
Search Principles for Businesses, Organizations
and Communities." But I want the link in the
Page list to be "Future Search Principles."
I want to avoid hard-coding the list links,
so any help you could provide would be great. Do you know of any plugins that would provide
this capability? If not, I would like to discuss costs for customization work.
Thank you!
By Lana on May 20, 2008
Hi Lana, your best option would be to add in either the SEO Title Tag plugin or the All-in-one SEO pack plugin, which will allow you to change the title of the page, then when you create your page your page link will use the title of the page specified at the top of the Write Page page, and the title of the page will use the custom title given using the plugin (if that all makes sense!).
By Sarah on May 20, 2008
I don't understand yet. But I have the All in One SEO installed, so I'll play around and see what happens. Thanks!
By Lana on May 20, 2008
I understand that I can change the Title tag using All in One SEO, and that's great. But for additional SEO purposes, I want the page "headline" to contain key words (in my theme, the page title/headline uses the H1 tag). So unless I've misunderstood your directions, I still have the same issue of the page headline being used to create the link text.
Sorry if I'm not being clear about what I want
By Lana on May 20, 2008
Hi Lana,
Alter your single.php page to not display the tag the_title() between the h1 tags, remove the h1 tags line in fact, then in your posts create your page headline title within the content area.
So you'd control your page title via the All-in-one SEO pack title box, you'd control your page heading via the content box by adding the title you want at the top between h1 tags, and then your page link anchor text is set in the page title box.
This is how I've done it on other sites without a problem
By Sarah on May 20, 2008
Woo hoo! That worked! I've spent hours searching for this information. Thank you so much.
Do you have a donation button?
By Lana on May 20, 2008
Glad to hear it Lana
Yes my donation button is on my plugins page 
By Sarah on May 20, 2008
"…hover your mouse over my pages on the right, 'Learn PHP' should display a tool tip of 'Reference Guide to PHP Tutorials on StuffBySarah'…"
Out of curiosity, I tried this (using Firefox 2) and the tooltip said, 'View all posts filed under 'Learn PHP.' Therefore, I assume you are no longer using the plugin.
As a non self-hosted WordpressMU user, the plugin wouldn't have been an option for me, but you made some good points in your post. Excessive use of the 'title' attribute is not only unnecessary; it's also bad for accessibility.
By Chris on Jun 10, 2008
Hi Chris, the plugin is still in use. You've hovered over the blog category Learn PHP, up top are my pages along the horizontal nav where you'll find the page. I know, it's confusing, I'll get that changed!
I must admit, it is quite surprising that WordPress uses it as default, and quite a few people are surprised when they find out from what I've seen. I completely agree with the RNIB over the issues of excessive use. I know a few developers that feel that it's acceptable, I guess they've never had to rely on a screen reader before.
By Sarah on Jun 10, 2008