WordPress – add meta tags: author, description, keywords, etc

After reading some SEO stuff I wanted to add some meta tags to my WordPress blog. I found this site: codex.wordpress.org/Meta_Tags_in_WordPress.
So WordPress thinks that it’s not necessary to have this meta tags any more… But I want it! 🙂 Next funny thing is how they suggest to add meta tags: copy header.php – what about theme updates?

I prefer to use functions.php file – just create it in your courrent theme directory with such content:

<?php
// this will remove WordPress version from header
remove_action('wp_head', 'wp_generator');

// handler function for adding custom tags
function custom_header_meta() {
?>
<meta name="author" content="Tomasz Gągor" />
<meta name="contact" content="my@mail.com" />
<meta name="description" content="<?php wp_title( '|', true, 'right' ); ?>" />
<meta name="keywords" content="some keywords" />
<meta name="verify-v1" content="google webmaster identification" />
<meta name="msvalidate.01" content="bing webmaster identification" />
<meta property="fb:admins" content="facebook identificatio" />
<meta name="copyright" content="Copyright (c)1997-2014 Tomasz Gągor. All Rights Reserved." />
<?php
}

// running handler function
add_action('wp_head', 'custom_header_meta');

2 thoughts on “WordPress – add meta tags: author, description, keywords, etc”

  1. I have notice by doing that the tag meta is generated twice. the first one with empty value, I guess added by wordpress core function, the other is the one we add in the function.php
    So how do we remove this duplication? or am I the only one having this problem?

    1. I’ve been doing this so long ago that something in WP might changed.
      Did you tried running remove_action before to remove unneeded headers?

Leave a Reply

Your email address will not be published. Required fields are marked *