I believe single_tag_title() only works with tag query results. When are you trying to place tags in the title?
Anyway, the code I put up here may be useful to you:
http://wordpress.org/support/topic/141783#post-642907
Thread Starter
snare
(@snare)
Now working great
<?php global $post;
if( is_single() || is_page() ) :
$tags = get_the_tags($post->ID);
foreach($tags as $tag) :
$sep = (empty($keywords)) ? '' : ', ';
$keywords .= $sep . $tag->name;
endforeach;
?>
<meta name="keywords" content="<?php echo $keywords; ?>" />
<?php $x = str_replace(", ", " ", $keywords); ?>
<title>
<?php wp_title(''); ?>
<?php if(wp_title(' ', false)) { echo ' | '; } ?>
<?php echo $x.' '; ?>
<?php bloginfo('name'); ?>
</title>
<?php endif; ?>
I have another problem when i check the code from source
<title>*[2 SPACE HERE] Saw IV Trailer | bla bla bla</title>
Check * marked place. It puts 2 space and after that it writes title. Why?
It’s due to a couple issues, one being the fact wp_title() outputs a an initial empty space already.
Anyway, I think this may work better for you:
<?php global $post;
if( is_single() || is_page() ) :
$tags = get_the_tags($post->ID);
if($tags) :
foreach($tags as $tag) :
$sep = (empty($keywords)) ? '' : ', ';
$keywords .= $sep . $tag->name;
endforeach;
?>
<meta name="keywords" content="<?php echo $keywords; ?>" />
<?php
endif;
endif;
$title = wp_title('', false);
if($keywords) {
$title .= ' | ' . str_replace(", ", " ", $keywords);
}
$title .= ' ' . get_bloginfo('name');
?>
<title><?php echo trim($title); ?></title>