Forums

Using tags as meta keywords (PHP question) (4 posts)

  1. LJK
    Member
    Posted 4 years ago #

    I'm trying to write a little bit of code so that the tags on my blog can be used as keywords in the <meta> part of the <head> on my site.

    So far, so good, I have:

    <?php echo '<meta name="keywords" content="';
    $posttags = get_terms('post_tag');
    if ($posttags) {
    foreach($posttags as $tag) {
    echo $tag->name;
    echo ", "; }
    echo '" />'; } ?>

    which works really well.

    However, I don't want my site to be penalised by search engines for having too many keywords, so I want to limit the amount of tags I show to maybe the 15 most popular.

    So, does anyone know how I can do this by adding to the code above? Or another way? (I am actually testing in 2.7 RC1, if that helps!)

  2. Josh Leuze
    Member
    Posted 4 years ago #

    There are some good plugins for SEO, the All in One SEO Pack will automatically generate meta tags for you.

  3. LJK
    Member
    Posted 4 years ago #

    Thanks jleuze but I'm trying to avoid relying on other people's plugins as this is for a theme I am building.

  4. Kejatz
    Member
    Posted 3 years ago #

    How to disable adding of tags in meta keywords in All in One SEO plugin? I want to write just my own keywords into meta keywords.

    Can this be done?

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic