Title Override
Purpose
Ever needed to override a Page’s title?
Usually WordPress uses the actual title of the Page to populate the <title> tag.
Depending on your theme it may stick a few other things there as well – blog name, a tagline, etc. Most of us do not give it too much attention until we realise two fascinating facts:
- When someone bookmarks the page in their browser, contents of the <title> tag are automatically used as the of the bookmark. Given that the menu width is often limited, you really want the first few words of the bookmark to be meaninful to the user.
- Search engines still pay attention to the <title> tag! (probably because it is supposed to be “vewer-focused” and thus less subject to tampering than the “keywords” meta tag.
This plug-in allows you to keep your page titles the way you like them, yet define what is included into the <title> tag in the <HEAD> section of your Pages.
Scope
This is a simple tool for a simple task.
Title Override defines alternative titles for Pages only. Not for Posts. (Not unless someone convinces me that it is worth the effort).
Title Override deals with <title> tag only. Not with “keywords” or “description” meta tags – there are plenty of excellent plug-ins for that. Do not even ask me to go there.
What it does, how it works
1. Title Override adds an extra field into your administrative Page Edit screen. This is where you enter your alternate title:
It effectively creates one more custom field and the fancy-shmency UI was not strictly speaking essential, but it does make things a bit less threatening for not computer-savvy users. Right?
2. There is no Options page – there is nothing to configure really.
3. Title Override installs a filter using wp_title() hook. If you enter anything into Title Override field – that is what wp_title() will output in your header (or wherever you use it). If you enter nothing, standard behavior of wp_title() will remain unchanged. So, if you activate this plug-in and never input anything into the Title Override field, there will be no impact on the output of your Pages (well, maybe a minor slowdown dues to a bit of extra processing).
4. For advanced users (comfy with editing header.php) Title Override includes an extra function: is_title_override()
Can you guess what it does? – Correct! It returns true if there is an alternate title defined for the current Page, and false otherwise. Now you can do something fancy like the example below:
<title>
<?php
if ( is_title_override() ) {wp_title();}
else: {
bloginfo('name');
_e(': ');
bloginfo('description');
_e(': ');
wp_title();
}
?>
</title>
I am sure you can thing of even more extravagant uses and would love to hear about them!
Credits
Title Override owes most of this code to the wonderful Headspace 2 plug-in. I did not ask its author John Godley for permission or help – his code was an inspiration enough. So, whan Title Override works – at least 80% of your thanks should be directed to John. When this plug-in horribly disfigures your server and ruins your marriage… I was going to put “the fault is mine” here, but read the disclaimer below!
Disclaimer
This is my first WordPress plug-in. I wrote it for my own purposes, not for public distribution. It is provided “As Is” and can probably do horrible harm.
I do not know PHP. I have never written a full PHP program in my life. Not even “Hello, World”. This means the code may be buggy and is guaranteed to be sub-optimal.
Parts of this plug-in came from other people’s code. I think I understand what they do, but not always why or how (this is especially true of the Ajax part).
Good luck!
Download
Have you read the Disclaimer above??? – download Title Override here: Title Override WordPress Plug-in Version 1.1.1
Installation
- Download the plugin (see “Download” above).
- Rename title-override.txt to title-override.php and put it into your plugins directory (/wp-content/plugins/) or in a sub directory of the plugins directory.
- Activate the Plug-in.
- Enjoy!
Change Log
Version 1.0, Dec 1′06 – original version with Ajax in the Edit screen.
Version 1.1, Dec 4′06 – no more Ajax – it was conflicting with the sidebar widget plug-in. Sorry, I am not smart enough to fix it. But the plug-in still works.
Version 1.1.1, Dec 9’06 – fixed a nasty bug that could make all your RSS feeds unacceptable to some readers. Sorry if it caused you trouble.
Thank you
Writing all this up took time and effort. If you happen to be actually using this plug-in – I appreciate your vote of confidence and would love to hear about it!
18 Comments
Jump to comment form | comment rss [?] | trackback uri [?]