SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Zealot MajorTom's Avatar
    Join Date
    Aug 2007
    Location
    Planet earth
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SEO Friendly Titles for Wordpress

    When you're optimizing a site for the search engines, the actual title in the title bar is the most important element. Unfortunately, a standard Wordpress install creates ugly titles for your individual posts.

    I wrote an article on how to edit your Wordpress software to fix that...

    <removed link>

    Hope this might be useful for any Wordpress users out there.
    Last edited by ses5909; Oct 11, 2007 at 05:07.

  2. #2
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good tips. I use similar method for my blogs.

    For me, I only put the blog name as title for the home page and all other pages like single post and categories will get their post name or category name as the page title.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    title hack

    Not bad. Any idea on how to get rid of the 2 leading spaces? The wp_title function wraps the separator in spaces, and the 2 spaces are then prefixed to the title and returned. I tried trim(), but no go.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    Not bad. Any idea on how to get rid of the 2 leading spaces? The wp_title function wraps the separator in spaces, and the 2 spaces are then prefixed to the title and returned. I tried trim(), but no go.
    trim() will work if you set the second argument of wp_title to false. That determines whether the function echos or returns a string.

    PHP Code:
    echo trim(wp_title(''false)); 

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    trim

    :do'h: I didn't think that the function either echos or returns based on the value of the argument until after I signed off. But yes, that does it.
    I notice that the "standard" un-hacked URL for the index page title has 2 trailing spaces. So that makes me wonder if the spaces are all that important SEO-wise? Or just something else to bug my perfectionist tendencies?

  6. #6
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for bringing this up. I am not aware of the 2 leading space problem until now. So I just added the trim() to the wp_title to remove it even though I don't think it will affect the SEO of the blog. Thanks guys.

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Location
    Europe
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good tip thanks. I've used Optimized Title Plugin untill now...

    Mails

  8. #8
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, good tip.
    Macro Expert
    handle repetitive/routine works http://www.macro-expert.com/
    http://mouse-recorder.macro-expert.com/
    GS Typing Tutor-Learn to touch type at http://www.typingstar.com/

  9. #9
    SitePoint Evangelist
    Join Date
    Apr 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For SEO friendly URL :

    go to Options

    then Permalinks

    then select custom and insert this:

    /&#37;category%/%postname%

    next to custom structure

    click save and you have search engine friendly urls for your blog pages


  10. #10
    SitePoint Evangelist
    Join Date
    Jul 2003
    Location
    uk
    Posts
    503
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just download the all in one seo pack plugin

  11. #11
    SitePoint Zealot MajorTom's Avatar
    Join Date
    Aug 2007
    Location
    Planet earth
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    Not bad. Any idea on how to get rid of the 2 leading spaces? The wp_title function wraps the separator in spaces, and the 2 spaces are then prefixed to the title and returned. I tried trim(), but no go.
    This should work...

    $string_to_trim = preg_replace("/^\s\s/", "", $string_to_trim);

    That's just a regular expression to anchor at the beginning of the string (^) and trim two white spaces (\s\s). $string_to_trim is the string you need to trim the white spaces from.

    Quote Originally Posted by Lastbutnotleast View Post
    For SEO friendly URL :
    go to Options
    then Permalinks
    then select custom and insert this:
    /%category%/%postname%
    next to custom structure
    click save and you have search engine friendly urls for your blog pages
    That's a good point but we're not talking about the url, we're talking about the title in the html output. Im assuming most people already have permalinks enabled. As an example of how and why what I'm doing works for SEO, if you Google "iWebTool Affiliate Program" (my post from October 3), my post is already on the first page of Google.


    Quote Originally Posted by Ross19821982 View Post
    Just download the all in one seo pack plugin
    That's all fine and dandy but the point of a "hack" is to learn how to code and learn how the Wordpress software operates, not to be dependent on code other people wrote.

  12. #12
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Here is the code I use for my title tags:

    Code:
     <title>
      <?php wp_title(' '); ?>
      <?php if(wp_title(' ', false)) { echo ' -'; } ?>
      <?php bloginfo('name'); ?>
     </title>
    which displays as:

    POST TITLE - BLOG NAME

  13. #13
    SitePoint Zealot MajorTom's Avatar
    Join Date
    Aug 2007
    Location
    Planet earth
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's similar to the code I posted on my blog which the moderators here deemed worthy to remove the link. The only reason I posted a link instead of posting the full article was because of fears of winding up in the duplicate content filter. Anyway, here's the code...

    Code:
    <title>
    <?php if ( is_single() ) {
    wp_title('', true);
    }else{
    bloginfo('name');
    wp_title();
    }?>
    </title>
    Depending on what theme youíre using, the file to edit will be in your /wp-content/themes/yourtheme directory and if there isnít a file named header.php (which is the usual edit spot), you will be editing the file index.php.

    Happy Wordpress Hacking

  14. #14
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    title hack

    I tried this in my theme's header.php file and it works OK
    PHP Code:
        <title><?php if ( is_single() )
        {
            echo 
    trim(wp_title(''false));
        } else {
            
    bloginfo('name');
            
    wp_title();
        } 
    ?></title>
    I'm still wondering, do " <-- outside spaces --> " affect SEO or do most already trim() anyway? It seems the spaces aren't in any browser title bar, but that's the browser.

  15. #15
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ever seen a page title in the SERPs with a bunch of spaces anywhere in it? Nope, they deal with ignoring 'em fine

  16. #16
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)

    spaces

    Now that I think about it, the spaces I've seen as "%20"s were, AFAIK, in links to pdf (and doc ?) files. So they were probably put there from an app.

  17. #17
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    &#37;20 is a urlencoded space... if someone is urlencoding text for a page title, they're just confused

  18. #18
    SitePoint Wizard cpvr's Avatar
    Join Date
    Apr 2004
    Location
    Spring, Texas
    Posts
    2,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, how many of you guys have the blog post name as your description too?

    IE: Welcome to blog, blog name
    Love pets? Why not discuss virtual pets?
    Contact me on Twitter @cpvr


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •