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 robThanks for the plugin bro. It is very useful.
Reply to Kenneth Lee<blockquot
e>
Reply to Wordpress Meta Tag/SEO pluginHey, Thanks for this useful article. Keep it up.
Reply to seo company ukHi! this is great, thanks.
Reply to AssasinThank u for the 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).
Reply to Memphis SEOthankks
about your article
Reply to educationHello All visitors by means off Shubhinetwork, we provide you an opportunity of online job,off add a posting which you can do sitting at your homes it self & also free off cost. So ShubhiNetwork Welcome Peoples from Any part of the world to come and join their hand with it. Sign up Free 100ore information visit below this site
———–
roxyrohit
————-
Reply to rohit.sirohiyaSEOSEO
Good plug-in, thanks
Reply to DudelkaAffordable Search engine optimization(SEO) Service from an Online Internet marketing company. outsource Seo services to India Seo company India. Seo Company Seo Services India from a professional SEO India.
Reply to navjeetWhy arenâ??t there options for actual plugins???
Reply to StephanGreat article on SEO.
Reply to seo arvinUseful script.
Reply to AsterHostThank You
very good
Reply to nantong seoI hit a link in google and read
Reply to seo jaipura blog on this site about the economic
strain we are taking in SA. I tried to
find it once I registered, unfortunately
to no avail. Perhaps somebody could be
so kind as to show me the way? Anyway,
I’m here and waiting!
————–
Rockstarbabu
—————-
oh, mate, it’s really useful, especially for my stupid russian hoster and its server
Reply to ÐеприврунOur Web & SEO consultants are experienced and qualified enough to fulfill your demands for complete web & SEO services in India.
Reply to seo expert IndiaThank u for the plugin that prevents duplicate content from being indexed by Google.
Reply to Manchester UK based Seo companyIt is surely a good post giving information about avoiding duplication content from being indexed by Google. I am just wondering how people who are not that knowledgeable in programming can use this.
I was searchign this plugin,thanks for sharing here, Iam thankful to you..
Reply to soniaOur Web & SEO consultants are experienced and qualified enough to fulfill your demands for complete web & SEO services in India.
Reply to seoI was searchign this plugin,thanks for sharing here, Iam thankful to you..
Reply to Desi Girls