Support » Fixing WordPress » Google friendly header idea from Codex?

  • The following header code I found in the Codex, doesn’t work. Why? The error message is “Parse error: parse error, unexpected ‘,’, expecting ‘)’ in /mysite/mysite/mysite/wp-content/themes/mysite/header.php on line 16

    I started with code from this page of the Codex:
    http://codex.wordpress.org/User:Yami_McMoots/My_Header

    So the behavior of wp_title() isn’t optimized for Googliciousness. Here’s how I have my page title set up in header.php:

    <title>
    <?php if (is_home () ) {
    bloginfo('name');
    } elseif ( is_category() ) {
    bloginfo('name'); echo ": "; single_cat_title();
    } elseif (is_single() || is_page() ) {
    single_post_title();
    } elseif (is_search() ) {
    bloginfo('name'); echo " search results: "; echo wp_specialchars($s);
    } else { wp_title(,true); }
    ?>
    </title>

    Can someone troubleshoot that code?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thanks Viper. That helped me figure out how to fix it easily.

    I like this on my blog, nice little improvement. For anyone who wants to try it, replace this code in your Header.php –

    <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Archive <?php } ?> <?php wp_title(); ?></title>

    with this (my corrected code) –

    <title>
    <?php if (is_home () ) {
    bloginfo('name');
    } elseif ( is_category() ) {
    bloginfo('name'); echo " - "; single_cat_title();
    } elseif (is_single() || is_page() ) {
    single_post_title();
    } elseif (is_search() ) {
    bloginfo('name'); echo " search results: "; echo wp_specialchars($s);
    } else { wp_title('',true); }
    ?>
    </title>

    You’ll see the effect in your browser title bar, not in your blog header. I don’t know if this really helps with Google results, but it’s cool.

    Now, if I can just figure out how to edit Yami’s original code I found on his User page in the Codex Wiki….?

    aggressiveskater

    (@aggressiveskater)

    This works! I made the changes to my blog on friday and today (two days later), I am number one on google for the phrase "aggressive skate blog"! This one change made a huge difference.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Google friendly header idea from Codex?’ is closed to new replies.