Created
May 7, 2013 17:42
-
-
Save geilt/5534558 to your computer and use it in GitHub Desktop.
Wordpress News Meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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