Support » Requests and Feedback » Add tags to meta keywords

  • ccarmical


    It would be nice if we could add the post tags to the meta keywords in the header. The current code apparently only works in the Loop.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Chris_K


    I’ve not tried yet, but I just saw reference to get_the_tags() and get_the_tag_list(). I wonder if either of those can be used outside the Loop?



    I would like put meta keywords but i dont know how to get all tag’s from current page. get_the_tag_list() doesnt work 🙁




    Thanks, HandySolo, but unfortunately those don’t seem to work outside the Loop, either.



    so? how to solve this problem?



    Dunno if this helps, but I’m using the HeadSpace2 plugin, which inserts WP 2.3 tags as keywords and a whole lot more.

    The plugin’s a little scary, because it offers so much control over meta keywords and description, title, etc, that I dunno what I’d do without it… In any case, I’ve used it for a few months with no problem, and it’s been updated for 2.3…



    Thanks, tbronson! That plugin works for me!



    Hi all, maxbmx, ccarmical, emm… I’ve been working about a simple function for metakeywords… without plugins.

    You can try with this:

    <meta name="keywords" content="<?php if(is_single()) {
    			$metatags = get_the_tags($post->ID);
    			foreach ($metatags as $tagpost) {
    				$mymetatag = apply_filters('the_tags',$tagpost->name);
    				$keyword = utf8_decode($mymetatag); // Your filters...
    				echo $keyword.",";
    		?>your,key,words" />

    Checkups it’s a personal work ^^
    Hope it useful.

    PD: Srry lang 🙁



    Thanks, Covi.



    I am using “All in One SEO Pack“. It’s easy to use and i like it.

    thanks covi, your snip works.

    This is what I use – I got it from another post and modified it so it works on home page too.

    The statements also make it so it does does not make xhtml errors if there are no keywords.

    <?php global $post;
    if( is_single() || is_page() || is_home() ) :
    	$tags = get_the_tags($post->ID);
    	if($tags) :
    		foreach($tags as $tag) :
    			$sep = (empty($keywords)) ? '' : ', ';
    			$keywords .= $sep . $tag->name;
    <meta name="keywords" content="<?php echo $keywords; ?>" />

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Add tags to meta keywords’ is closed to new replies.