Forums

Add tags to meta keywords (12 posts)

  1. ccarmical
    Member
    Posted 1 year 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. HandySolo
    moderator
    Posted 1 year 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 1 year 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 1 year ago #

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

  5. maxbmx
    Member
    Posted 1 year ago #

    so? how to solve this problem?

  6. tbronson
    Member
    Posted 1 year 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 1 year ago #

    Thanks, tbronson! That plugin works for me!

  8. Covi
    Member
    Posted 1 year 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 1 year ago #

    Thanks, Covi.

  10. kansir
    Member
    Posted 1 year ago #

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

  11. myst1c
    Member
    Posted 8 months ago #

    thanks covi, your snip works.

  12. estjohn
    Member
    Posted 4 months 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