Forums

Customize Static Page Title Tags (3 posts)

  1. elbalazo
    Member
    Posted 2 years ago #

    Hi, I have asked this before, but I'm just not able to resolve this.
    How can I hack WP to be able to create custom <title> tags for my static pages? Plugin or loop hack will do.
    Thanks!

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    you could some code like this:

    <title>
    <?php if(is_page('3')) { echo 'custom title tag of page 3'; }
    elseif(is_page('17')) { echo 'custom title tag of page 17'; }
    else { wp_title('&laquo;', true, 'right'); bloginfo('name'); } ?></title>

    conditional tags:
    http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page

    question: where and how would you define/save the custom titles?
    if you are using custom fields, you code could look something like this:

    <title>
    <?php if(is_page()) { echo get_post_meta($post->ID, 'custom_title', true); }
    else { wp_title('&laquo;', true, 'right'); bloginfo('name'); } ?></title>

    (not tested)

    depends on the current code of the title tag, and what you would like to show if it is not a page.

    i assume that some seo plugins might handle custom title tags for pages as well.

  3. elbalazo
    Member
    Posted 2 years ago #

    Hi there and thanks,
    I want to include a custom field to manually enter the title tag contents. I'll give this code a try.
    Cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic