Word Press PHP title not showing on home page - others work

Discussion in 'PHP' started by loopline, Dec 22, 2009.

  1. #1
    So I have modified my title for my Wordpress Blog. The current setup should change the category to reflect the title of the page that I want. However my home page title is blank. Every other page title seems to work fine.

    Here is what is in my header.php file for my theme I am using:

    <title><?php if ( is_category() ) { ?> Windows Vista <?php wp_title(''); ?> <?php } else { ?><?php wp_title(''); ?> <?php }?></title>
    Code (markup):
    It used to work, but after some recent upgrades it no longer seem to show. It just pulls a blank title.

    site:
    http://themes4vista.com
    Code (markup):
    Any ideas why? I am drawing a blank.
     
    loopline, Dec 22, 2009 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The code looks fine. Do you have any seo plugins that might need you to set the home title individiually?
     
    JAY6390, Dec 22, 2009 IP
  3. loopline

    loopline Well-Known Member

    Messages:
    738
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    130
    #3
    I don't have any seo plugins at all. :) Not sure why it would do that. The home page is an actual page. Could I just modify the code in the title to add an extra "else if" statement that if its that page display X title?

    If so how would I do that? The above code is code I hacked together from another site. Im only just above beginner in PHP.

    Thanks for your time.
     
    loopline, Dec 22, 2009 IP
  4. CodedCaffeine

    CodedCaffeine Peon

    Messages:
    130
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <title><?php echo ( is_category() ? 'Windows Vista ' : ''), wp_title('', false, ''); ?></title>
    PHP:
    I'm pretty sure that will work. I shortened it a little and rewrite wp_title with the proper parameters. Hope it works!
     
    CodedCaffeine, Dec 23, 2009 IP
  5. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Does the page actually load the header anywhere? I think WP lets you override the themes with your own pages, so that might be the problem
     
    JAY6390, Dec 23, 2009 IP
  6. sevnrock

    sevnrock Peon

    Messages:
    241
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try this. I used to have problems when using php inside titles for some reason, so I would just echo everything. Works the same.

    <?php

    if (is_category()){
    echo "<title>Windows Vista "; wp_title();
    echo "</title>";
    }

    else {
    echo "<title>";
    wp_title();
    echo "</title>";
    }

    ?>
     
    sevnrock, Dec 23, 2009 IP
  7. loopline

    loopline Well-Known Member

    Messages:
    738
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    130
    #7
    Yeilded the same result as the existing code. Everything works but the home page. Weird. Thanks for cleaning it up though. :)

    Yes, I tested just putting actual text in and it loads.

    Yielded the same result as existing code.

    Thanks for all the suggestions guys.

    At a loss. Any more thoughts welcome.
     
    loopline, Dec 23, 2009 IP
  8. sevnrock

    sevnrock Peon

    Messages:
    241
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Try this instead

    <?php

    if (is_category()){
    echo "<title>Windows Vista "; wp_title();
    echo "</title>";
    }

    elseif (is_home()) {
    echo "<title>";
    wp_title();
    echo "</title>";
    }

    else {
    echo "<title>";
    wp_title();
    echo "</title>";
    }

    ?>
     
    sevnrock, Dec 23, 2009 IP
  9. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I really can't see echoing title tags being an issue to be honest. It must be something set in WP that is causing the blank title. What version are you using?
     
    JAY6390, Dec 24, 2009 IP
  10. loopline

    loopline Well-Known Member

    Messages:
    738
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    130
    #10
    I would have thought that would work, I manually added my title to the else if in your code, but it still didn't show. Which makes me think that it isn't recognizing the is_home() or something. Wierd cause if I just put plain text it works fine.

    I agree, I don't see how echoing the title tags would make a difference. But I am willing to try anything.

    You do bring up an interesting point. I have Version 2.9. It has worked in previous versions. But it has been a long time since I have messed with the title and several versions of wordpress. Its just not something I ususally check to see if its there.
     
    loopline, Dec 24, 2009 IP