WordPress Meta Tag/SEO plugin
Posted on Wednesday the 7th of March, 2007 at 2:09 pm in PluginsI was sick of having a half dozen different plugins to add meta tags and fix the robots, so I wrote a plugin that prevents duplicate content from being indexed by Google, adds useful meta tags, and ensures that all posts are at one single permalink (using 301 redirects of course). This is more a shell of a plugin than an actual plugin as there are no options, and there are obvious flaws such as it doesn’t allow you to use paged posts. If you want to make changes you will have to do it yourself.
Copy the following into a php file. Upload it. If you need any more instructions than that, you are better off using a plugin that is a little more user friendly because using this plugin incorrectly can kill your site.
<?php/* Plugin Name: Ultimate SEO Plugin URI: http://anthologyoi.com/ Description: This plugin combines the functionality of other SEO plugins. Author: Aaron Harun Version: 0.0 Author URI: http://anthologyoi.com/ */add_action('wp_head', 'seo_head');add_action('wp_head', 'seo_permalink');function seo_head() {if((is_home() && ($paged <2 )) || is_single() || is_page()) {$meta = '<meta name="ROBOTS" content="index,follow"/>';} else {$meta = '<meta name="ROBOTS" content="noindex,follow"/>';}echo $meta;echo '<meta http-equiv="Pragma" content="no-cache" /><meta http-equiv="Cache-Control" content="no-cache, must-revalidate" /><meta http-equiv="Expires" content="-1" /><meta name="copyright" content="© 2005 - 2007 - Anthology of Ideas" />';echo '<meta name="description" content="';if ( is_404() ) {echo '404, Page Not Found. Sorry, but the page you requested cannot be found';}elseif ( is_search() ) {echo 'Search Results for '.$search;}elseif ( is_archive() ) {echo ucfirst(strip_tags(single_cat_title())).' from Anthology of Ideas.';}elseif((is_page() || is_single()) && !is_tag()){echo seo_excerpt();}else{echo bloginfo('description');}echo '" />';echo '<meta name="name" content="';bloginfo('description');echo '" /><meta name="rating" content="general" /><meta name="expires" content="never" /><meta name="distribution" content="global" /><meta name="revisit-after" content="15 days" />';}function seo_permalink() {global $withcomments,$post,$wp_query;$cur_url = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];if(is_single()){$permalink = get_permalink($post->ID);}elseif(is_page()){$permalink = get_page_link($post->ID);}elseif(is_category()){$cat = $wp_query->get_queried_object();$permalink = str_replace('./','',get_category_link($cat->cat_ID));}if (!$permalink)return;if ($permalink != $cur_url) {header('HTTP/1.1 301 Moved Permanently');header('Status: 301 Moved Permanently');header("Location: $permalink");exit(0);}}function seo_excerpt($word_limit=40){global $post;if ( !empty($post->post_password) ) { // if there's a passwordreturn false;}// decide on the contentif ($post->post_excerpt != ''){$output = $post->post_excerpt;}else{$content = $post->post_content;$content = strip_tags($content);//$content = str_replace(array(chr(13),"\n","\r", ' ' ), ' ', $content);$content = preg_replace('/\s+/',' ',trim($content));$words = explode(' ', $content, $word_limit + 1);if (count($words) > $word_limit) {array_pop($words);array_push($words, '...');$output = implode(' ', $words);}else{$output = $content;}}//$output = apply_filters('the_excerpt', $output);if(strpos($output,'UTW_')==true){$output = '';}return $output;}?>- Use the following to copy and paste the code.


Why aren’t there options for actual plugins?
Reply to FarazBecause this was just a script I wrote for myself that I posted in case someone else needed it.
Reply to Aaronthis is great, thanks.
Reply to robHi! this is great, thanks.
Reply to AssasinGood plug-in, thanks
Reply to Dudelkaoh, mate, it’s really useful, especially for my stupid russian hoster and its server
Reply to НеприврунWell its a good idea to hide duplicate content but I prefer to post new content and get it indexed so the search engines rank me better.
Reply to KaxiiCheers
This is best one article so far I have read online. I would like to appreciate you for
making it very simple and easy. I have found another nice post related to this post over
the internet which also explained very well. For more details you may check it by visiting this url…
http://mindstick.com/Articles/a70d80fd-c9c8-4d51-864b-39c3b1c9ba31/?Meta%20Tags%20in%20WordPress
Thanks
Reply to Manoj Bhatt