I’d like my unique Pages to have a more ‘sexy’ title than merely ‘home’ and ‘portfolio’, but when I change their titles to something more descriptive like ‘my fantastic page all about kitchen units’ then the list of pages in my sidebar changes to show this rather lengthy title.
Can I have ‘sexy’ Page meta titles, but maybe base the sidebar links on the Page slug? I’d rather not use the Links module as my site navigation, as I don’t use it on all my Pages.
How about using custom fields for this?
Set a custom field with a key of ‘title’ (no quotes) and the sexy Page meta title for the value. Then in your Page template where the_title() is put to use, replace it with this:
$sexy_title = get_post_custom_values('title');
$title = ($sexy_title) ? $sexy_title : get_the_title();
In summary, the code collects the value(s) for the custom field key ‘title.’ The second line assigns $title the value of the custom field if it exists, otherwise it sets $title to the regular Page title. Then it echos (displays) it.
Amazing how those custom fields can be used for almost anything…
Just an SEO consideration, google seems to look at the URL for keywords as well as page title, so providing your post slug is of reasonable length it may not be such a bad thing.
Kafkaesqui, I tried that and it just displays the default title for that Page. Incidentally, I don’t have the_title() in my header.php file, only wp_title(), does this make a difference?
I ended up using this solution: http://wordpress.org/support/topic/52216?replies=4
- The topic ‘Title tag vs Slug – who will win?’ is closed to new replies.