• Home
  • About
  • Job Profile
  • Portfolio
  • Training
Blue Orange Green Pink Purple

SEO meta techniques for a wordpress blog

Posted in Wordpress. on Tuesday, August 19th, 2014 by lazyboy Tags: seo, wp
Aug 19

SEO became the important part of websites. WordPress comes with the great concept of blog, CMS and with nice SEO support. Although I’m sharing here the some techniques for basic meta for different pages in wordpress to be handled in a common header section upon your page type, content. Here goes my thoughts…

Basically 3 most common part/page used in a wordpress blog/site, where we goes for visit are

single.php for single post
category.php for any type category/term
index.php for blog home/default template for other types

At first we have common meta tags which will be used if not a single post or category page requested. For category page, we taken category title as a meta keyword and titles of posts under the category as a meta description. For single post page, post title as as meta description and post tags are as meta keywords. Finally a common meta key/description for index/home or other requested page. Here goes the code snippet:

<?php
if(is_category()){
    $cat = get_query_var('cat');
    $cmeta_desc = '';
    $cposts = get_posts(array('numberposts' => -1, 'post_type' => 'post', 'category' => $cat));
    if($cposts){
        foreach ($cposts as $ck => $cp) {
            $cmeta_desc .= $cp->post_title.",";
        }
    }
    $cmeta_desc = rtrim($cmeta_desc, ",");
    ?>
    <meta name="description" content="<?php echo $cmeta_desc;?>">
    <meta name="keywords" content="<?php single_cat_title();?>">
<?php
} else if(is_single()) {
    $tags = '';
    $tag_list = wp_get_post_tags($post->ID);
    foreach ($tag_list as $tk => $tag) {
        $tags .= $tag->name.",";
    }
    $tags = rtrim($tags, ",");
?>
    <meta name="description" content="<?php echo $post->post_title;?>">
    <meta name="keywords" content="<?php echo $tags;?>">    
<?php
} else {
?>
    <meta name="description" content="PHP developer, tech savvy, tech blogger, freelancer">
    <meta name="keywords" content="php, mysql, wordpress, codeigniter, web developer, freelancer, web consultant">  
<?php
}
?>

Hope this will give you guys some idea as well as some help in wordpress.

Happy blogging!

Saif The Green

  • View Saif's profile on LinkedIn
  • Recent Posts
    • RESTful API – The HTTPish …
    • SUSE – another user-friendly desktop Linux distributions
    • SEO meta techniques for a wordpress blog
    • Set favicon in cross browser and more…
    • WordPress custom URL rewrites and tips
  • Archives
    • October 2016
    • August 2016
    • August 2014
    • July 2014
    • April 2014
    • June 2013
    • April 2013
    • March 2013
  • Categories
    • CodeIgniter
    • Javascript
    • Linux
    • MySQL
    • opencart
    • php
    • SEO
    • Software Development
    • Web Development
    • Web Services
    • Wordpress
  • Meta
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Archives
    • October 2016
    • August 2016
    • August 2014
    • July 2014
    • April 2014
    • June 2013
    • April 2013
    • March 2013
  • Search







Saif The Green is proudly powered by WordPress
Entries (RSS) and Comments (RSS).