How to SEO without “All in one seo packs”
I am a big fan of plugins All In One SEO Pack, so almost all my WP blogs using this plugin, but of course the existence of the plugin – no matter how powerful role – has a bad effect for the performance of the database, now therefore I prefer to use php code as an alternative plugin.
Because of the existence of the plugin, reproduce count database querry and have an effect on safety factor IF plugin is no longer in care by the owner so that the open space for malicious scripts.
As we know, that AIOSP optimizing several factors:
1. Meta description of each page, can be automatically or in written
2. Keyword tags on each page
3. Canonical URLs
4. No-index on the archives, categories and tags (if it depends on the choice)
5. Structural setting Title
Actually without plugins All In One SEO Pack or a similar plugin, we can have the above factors, with enough add some PHP code, if the View Source in the bottom of the title will seem a meta description and title:
1. Meta Description displays in each article
So, to display the meta description Put the following code at the bottom of header.php on or after the tag <title>:
<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name="description" content="<?php the_excerpt_rss(); ?>" />
<?php endwhile; endif; elseif(is_home()) : ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<?php endif; ?>
So every article we have a meta description, a quote taken RSS, and this code will take the first paragraph quotes automatically, so after you publish an article then meta description will appear immediately
But you can “Rewrite” by writing a description as well as the All In One SEO Pack.
2. display Meta Keyword In Every Home
And to display the keywords of “Post Tags” in every article, then enter this code in the “function.php” before the tag?> Closing, like this:
function csv_tags() {
$posttags = get_the_tags();
foreach((array)$posttags as $tag) {
$csv_tags .= $tag->name . ',';
}
echo '<meta name="keywords" content="'.$csv_tags.'" />';
}
Then, enter this code <? Php csv_tags ();?> In the header and combine with the code above meta description, so the full form like this:
<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name="description" content="<?php the_excerpt_rss(); $post_desc_length = 20; ?>" />
<?php csv_tags(); ?>
<?php endwhile; endif; elseif(is_home()) : ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<?php endif; ?>
3. Meta Keyword in Home Page or the Homepage,
For keywords that appear only on the homepage can add the following tag:
<meta name="keywords" content="Keyword1, Keyword2, Keyword3" />
So the overall form as below
<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name="description" content="<?php the_excerpt_rss(); $post_desc_length = 20; ?>" />
<?php csv_tags(); ?>
<?php endwhile; endif; elseif(is_home()) : ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<meta name="keywords" content="Keyword1, Keyword2, Keyword3" />
<?php endif; ?>
4. Using Robots.txt for NO Index Archive, Category, Tag and others
If we want to “no-index” folder or file, simply create a robots.txt file with a notepad or text editor of your choice, then enter the file names that do not want in Google’s index like this:
User-agent: *
Disallow: /cgi-bin
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content/plugins
Disallow: /wp-content/cache
Disallow: /wp-content/themes
Disallow: /archives/
Disallow: /wp-
Disallow: /comments/feed/
Disallow: /trackback
Disallow: /feed
Disallow: */trackback
Disallow: */feed
Disallow: /*?*
Disallow: /*?
Allow: /wp-content/uploads# Google Image
User-agent: Googlebot-Image
Disallow:
Allow: /*# Internet Archiver Wayback Machine
User-agent: ia_archiver
Disallow: /# digg mirror
User-agent: duggmirror
Disallow: /
Then upload to root directory
5. Canonical URL?
No confusion, to have a canonical url, you just upgrade to WordPress 2.9 to above it will automatically have a canonical url like this in view souce
<link rel=’canonical’ href=’http://alaskanliturgicalsupply.com/xxxx-xx-xxx-xxx.html’ />
6. Title Blog and SEO friendly article
One more from the area of SEO Pack plugin that we can use it without a plugin, is to edit the title tag with the tag a more SEO friendly like this:
<?php wp_title(' '); ?> <?php if(wp_title(' ', false)) { echo ' : '; } ?><?php bloginfo('name'); ?>
7. Done!
Now, every article in our WordPress has a meta description and keywords that are also unique canonical url plus the title, without using plugins All In One SEO Pack or plugin that has the same function.
Bug:
but this way has a problem, if you use a plugin called YARPP related post (Yet Another Related Post Plugin), because the titles of YARPP will appear on meta description, if someone wants to use this way but still want to show related post, it must be non – Plugin YARRP-activate and use another plugin that works the same, or use the following PHP code to display related posts without a plugin:
<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo 'Related Posts';
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>5,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<ol><li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li></ol>
<?php
endwhile;
wp_reset_query();
}
}
?>
So the bug disappeared and once again we have reduced the use of plugins on WordPress blog us!
There are 3 plugins that we reduce, if using this method are:
* All In One SEO Pack
* Robots.txt
* Yet Another Related Post
Hopefully useful and I’ll see you next post!