Forums

[resolved] meta tag problem (4 posts)

  1. xinfo
    Member
    Posted 3 years ago #

    Hii

    i found adding auto meta tag plugin
    http://www.raoul.shacknet.nu/2006/01/05/add-meta-tags-wordpress-plugin

    problem is it show description as first few word from post and category name as keyword

    i like to show post title as descrption do its possible to modify the code

    present code in the plugin

    function amt_add_meta_tags() {
    global $posts;

    if ( is_single() ) {
    // Description
    $my_metatags = "\n<meta name=\"description\" content=\"" . strip_tags(get_the_excerpt()) . "\" />";
    // Keywords
    $my_metatags .= "\n<meta name=\"keywords\" content=\"";
    foreach((get_the_category($posts[0]->ID)) as $cat) {
    $my_metatags .= $cat->category_nicename . ', ';
    }
    $my_metatags = substr($my_metatags, 0, -2) . "\" />\n";
    }
    echo $my_metatags;
    }

    add_action('wp_head', 'amt_add_meta_tags');

    ?>

  2. petit
    Member
    Posted 3 years ago #

    My advice would be to contact the plugin author. He/She would probably know how to manage that.
    Someone her with more PHP experience, certainly knows to.

    Feel invited ;)

  3. Kafkaesqui
    Moderator
    Posted 3 years ago #

    Try altering the first $my_metatags line (under the 'Description' comment line) to:

    $my_metatags = "\n<meta name=\"description\" content=\"" . strip_tags($posts[0]->post_title) . "\" />";

  4. xinfo
    Member
    Posted 3 years ago #

    Thank you Kafkaesqui

    its working Great

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.