Alexander Conroy

How to Add Google News Meta with WordPress Tags

Add this code to your functions.php in your WordPress Themes folder to automatically add “news_keywords” into your HTML.  The news_keywords meta is a new way to tag news articles that allows webmasters to assist Google News in categorizing posts.

 * Title: News Meta Function
 * Author: Alexander Conroy
 * Version: 1.0.1
 * Website:
 * Purpose: Tags Tags for Current Post and puts it in the header meta comma separated maximum 10 tags.
 * License: GPLv3+

add_action('wp_head', 'news_meta');
function news_meta() {
	$posttags = get_the_tags();
	if ($posttags):
		$count = 1;
		foreach($posttags as $tag) :
			if($count == 10) break;
	    		$meta_tags[] = $tag->name;
		$meta_tags_text = implode(',', $meta_tags); 
		echo '' . PHP_EOL;