Skip to content

Instantly share code, notes, and snippets.

@geilt
Created May 7, 2013 17:42
Show Gist options
  • Save geilt/5534558 to your computer and use it in GitHub Desktop.
Save geilt/5534558 to your computer and use it in GitHub Desktop.
Wordpress News Meta
<?php
/*
* Title: News Meta Function
* Author: Alexander Conroy
* Version: 1.0.1
* Website: http://www.esotech.org
* 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;
$count++;
endforeach;
$meta_tags_text = implode(',', $meta_tags);
echo '<meta name="news_keywords" content="' . $meta_tags_text . '">' . PHP_EOL;
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment