Posted By

paulgrenwood on 09/23/09


Tagged

wordpress seo customfields


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vintagekrug


Custom Fields - SEO Your Title Tag


 / Published in: PHP
 

Search Engine Optimisation, or SEO is something that a lot of bloggers get obsessed about, whilst others think it’s a load of rubbish. I’m halfway between the two – whilst I believe that you can change certain things to better SEO your content, such as adding H1, H2 etc tags in the appropriate places, I personally don’t think you should get too carried away with it. One of the things you can do though is change your title tag, and this custom field trick will let you set a custom field and it’ll appear as your title tag. Add the code below to your header.php file:

  1. <?php $title = get_post_meta($post->ID, 'post-img', true);
  2. if ($postimageurl) {
  3. ?>
  4. <title><?php echo $title; ?></title>
  5. <?php } else { ?>
  6. <title><?php wp_title(''); ?> | <?php bloginfo('name'); ?></title>
  7.  
  8. <?php } ?>
  9.  
  10.  
  11. //Then, you can create a custom field <title> and it’ll appear as your title! If no custom field is set then a blog-standard title is displayed.

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: seo on November 9, 2009

Thanks that is what l think seo is a bit more than a few H tags

Posted By: seo on November 9, 2009

Thanks that is what l think seo is a bit more than a few H tags

You need to login to post a comment.