WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Title tag vs Slug – who will win?

[Resolved] Title tag vs Slug – who will win?

  • Hello,

    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.

    Any suggestions?

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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:

    <?php
    $sexy_title = get_post_custom_values('title');
    $title = ($sexy_title) ? $sexy_title[0] : get_the_title();
    echo $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, thanks – I’ll try that and report back…

    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

    Sorry plinth, I misunderstood where you wanted to place this title. But I’m glad you found a solution.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Title tag vs Slug – who will win?’ is closed to new replies.