1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Code Snipped for better META Keywords (Wordpress)

Discussion in 'Blogging' started by dichotom, Oct 9, 2009.

  1. dichotom

    dichotom Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2008
    Messages:
    1,920
    Likes Received:
    544
    I was doing some SEO on a couple blogs today and came up with this, it takes your post title and turns it into meta keywords. Just edit your header.php for your theme and put it above </head>. Works better than all in one seo for me, especially if you are autoblogging.

    Code:
    <meta name="keywords" content="keyword, another kw, <?php
    		global $post;
    		$key = $post->post_title;
    		$key = str_replace(",", "", $key);
    		$key = str_replace("  ", " ", $key);
    		$key = str_replace(" ", ", ", $key);
    		echo $key;
    		?>, yet another kw" />
    
    Basically it just gets rid of any existing commas and extra spaces, adds commas back between the words and echos them out. As you can see above you can easily add static keywords around the dynamic ones it generates. You can also not do that. :D I haven't tested this on 100 blogs or anything but it's not like it will splode your site if a keyword or two are strange, and from what I saw of it beats hell out of what AIO was doing anyway so you can't really lose here. If you have a problem or a cool modification, please post!
     
    • Thanks Thanks x 1
  2. boiler

    boiler Power Member

    Joined:
    Apr 27, 2009
    Messages:
    677
    Likes Received:
    127
    Home Page:
    it was good idea, how was the result anyway ?
     
  3. dichotom

    dichotom Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2008
    Messages:
    1,920
    Likes Received:
    544
    It worked great for me :) As far as results with search engine, I just did it so I don't know. I just thought it was nifty when I did it and it was better than using the crappy tags that AIO was throwing in there. All my titles have the exact keywords I am shooting for, so I can only imagine it is an improvement on the two sites I did it with.
     
  4. sidddd

    sidddd Power Member

    Joined:
    May 15, 2008
    Messages:
    749
    Likes Received:
    460
    Pardon my understanding.. can I have an example?

    You mean to say if the title is - BEST HOME IMPROVEMENT TIPS then it will convert it to BEST, HOME, IMPROVEMENT, TIPS ?
     
  5. dichotom

    dichotom Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2008
    Messages:
    1,920
    Likes Received:
    544
    That is what it does as it stands, which is optimal for my site, if you wanted them all together you could take out all the comma swapping and put

    Code:
    <meta name="keywords" content="keyword, another kw, <?php
    		global $post;
    		$key = $post->post_title;
    		echo $key;
    		?>, yet another kw" />
    
    Or if you need something more advanced we could apply some regex to the mix
     
  6. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    789
    Likes Received:
    3,129
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    Google quit paying attention to keywords after they realized they can be easily faked. Now they focus more on the titles and on the actual words on the page. I get better results from putting the search terms at the very bottom of the page, as opposed to putting them in the meta tags.
     
  7. bzy39

    bzy39 Regular Member

    Joined:
    Jan 15, 2009
    Messages:
    434
    Likes Received:
    239
    how to do that in wp, and automatic of course :D
     
  8. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    789
    Likes Received:
    3,129
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    1. make a list of the search terms (use the script that i posted here several months ago).

    2. paste the words onto the page...

    simple! :D
     
  9. dichotom

    dichotom Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2008
    Messages:
    1,920
    Likes Received:
    544

    I didn't mean for this to replace anything else, of course you are right that on the page is better, this was just the last thing on my pages that wasn't really optimized and I was nitpicking a way to make it do what I wanted :) I am positive that it can't hurt anything at any rate.
     
  10. oxonbeef

    oxonbeef BANNED BANNED

    Joined:
    Jan 4, 2009
    Messages:
    2,242
    Likes Received:
    7,872
    Looking for a post a couple of months old on this board is like trying to dig
    your way to the center of the earth. Any chance of finding that script for
    us?
     
  11. dichotom

    dichotom Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2008
    Messages:
    1,920
    Likes Received:
    544
    Search terms should be in the page already, why else would you bother posting something?
    Bottom of the page is weighted less than in the upper parts also, so you would be better off putting them up top if you forgot to include any related search terms that you are targetting in the original article in the first place.
     
  12. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    789
    Likes Received:
    3,129
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    • Thanks Thanks x 1