I’m looking for the exactly same thing. No luck so far 🙁 Any ideas?
To echo a list of tags from a particular post outside the Loop, you can set $post global, then do a foreach loop to echo the tags as normal.
For example, I use this loop to display post tags as meta keywords in my header if the page is a single post page.
<?php
global $post;
foreach(get_the_tags($post->ID) as $tag) {
echo $tag->name . ', ';
}
?>
Cool stuff.
This is a bit of code I have been working on. In this example the rtrim function removes the last comma of the last word in the list:
<?php
$posttags = get_the_tags();
foreach((array)$posttags as $tag) {
$show_tags .= $tag->name . ',';
}{
$rel_art .= rtrim($show_tags , ',');{
}
print $rel_art;
}
?>
Based on the examples shown here:
http://www.nathanrice.net/blog/ultimate-guide-to-wordpress-seo-meta-keywords/
http://phphelper.wordpress.com/php-rtrim-function/