WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Title tag vs Slug - who will win? (7 posts)

  1. plinth
    Member
    Posted 7 years ago #

    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?

  2. Kafkaesqui

    Posted 7 years ago #

    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...

  3. h8dk97
    Member
    Posted 7 years ago #

    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.

  4. plinth
    Member
    Posted 7 years ago #

    Kafkaesqui, thanks - I'll try that and report back...

  5. plinth
    Member
    Posted 7 years ago #

    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?

  6. plinth
    Member
    Posted 7 years ago #

    I ended up using this solution: http://wordpress.org/support/topic/52216?replies=4

  7. Kafkaesqui

    Posted 7 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags