Adding meta tags to WordPress
By default WordPress doesn’t output the tags you set on a post anywhere in the page source. According to this article meta tag support was removed from WordPress.
I’m not big on SEO, but apparently search engine crawlers love meta tags, and that helps ranking. After some poking around I got the feature working on the blog. Here’s how to add meta tags to WordPress:
- Edit
functions.phpin the theme folder. Add this function:
function tags2meta() {
$posttags = get_the_tags();
foreach((array)$posttags as $tag) {
$tags4meta .= $tag->name . ',';
}
if (!is_single()) { ?>global,tags,for,posts<?php }
echo "$tags4meta";
}
- Call this function in the header. Edit
header.phpin the theme folder, find the first<metaoccurrence and insert this right after it:
<meta name="keywords" content="<?php echo tags2meta(); ?>" />
Now you can see the post’s tags in the meta tag in the page source

And here’s how they look on the page:

