WordPress.org

Ready to get started?Download WordPress

Forums

Add tags to meta keywords (12 posts)

  1. ccarmical
    Member
    Posted 6 years ago #

    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.

  2. Chris_K
    Member
    Posted 6 years ago #

    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?

  3. maxbmx
    Member
    Posted 6 years ago #

    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 :(

    HELP

  4. ccarmical
    Member
    Posted 6 years ago #

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

  5. maxbmx
    Member
    Posted 6 years ago #

    so? how to solve this problem?

  6. tbronson
    Member
    Posted 6 years ago #

    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...

  7. ccarmical
    Member
    Posted 6 years ago #

    Thanks, tbronson! That plugin works for me!

  8. Covi
    Member
    Posted 6 years ago #

    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 :(

  9. ccarmical
    Member
    Posted 6 years ago #

    Thanks, Covi.

  10. kansir
    Member
    Posted 6 years ago #

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

  11. myst1c
    Member
    Posted 6 years ago #

    thanks covi, your snip works.

  12. estjohn
    Member
    Posted 5 years ago #

    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;
    		endforeach;
    ?>
    <meta name="keywords" content="<?php echo $keywords; ?>" />
    <?php
    	endif;
    endif;
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic