Integrare metatags di Add Meta Tags e Ultimate Tag Warrior

Come fare coesistere due plugin che inseriscono metakeywords nell’head dei post in Wordpress?

Fino ad ora ho utilizzato il plugin Add Meta Tags per gestire i tag meta nell’head del mio blog, che poneva come keywords dei miei post le categorie a cui erano assegnati.

Ora però ho integrato Ultimate Tag Warrior 3, plugin che offre la possibilità di inserire come meta keywords i tag assegnati ad un post.

Il dilemma è sorto spontaneo: come integrare i due? Add Meta Tags mi serve perchè aggiunge dei meta tags alla homepage, cosa che mi Ultimate Tag Warrior non fa.

Così ho modificato Add Meta Tags in modo che non entri in azione quando ho a che fare con un post, mentre agisca quando sono in homepage.

Come? Nella funzione function amt_add_meta_tags() ho commentato il blocco
if ( is_single() || is_page() ) {

ed ho sostituito

} elseif ( is_home() ) {
con

if ( is_home() ) {

Condividi questo post: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
Tags: , , , , , , ,
Articoli correlati:

2 Commenti al post “Integrare metatags di Add Meta Tags e Ultimate Tag Warrior”

  1. Alessio Says:

    Anche io vorrei attuare la tua modifica.
    Ho installato la Version: 1.2 di Add Meta tags.Devo chiederti due cose.
    1) Cosa intendi per ‘ho commentato il blocco
    if ( is_single() || is_page() ) {’ ?

    2) La parte da sostiruire
    } elseif ( is_home() ) {
    è’ quella della riga 444 ?

  2. Copes Flavio Says:

    Per chiarezza ti riporto l’intera funzione amt_add_meta_tags() così come l’ho modificata. La risposta alla tua prima domanda è che ho commentato l’intero blocco, quindi tutta la direttiva if.

    In pratica non visualizzo i tags se sono nella pagina singola o in un post, mentre li visualizzo negli altri casi.

    function amt_add_meta_tags() {
    /*
    This is the main function that actually writes the meta tags to the
    appropriate page.
    */
    global $posts, $include_keywords_in_single_posts;

    // Get the options the DB
    $options = get_option(”add_meta_tags_opts”);
    $site_wide_meta = $options["site_wide_meta"];

    $my_metatags = “”;

    // if ( is_single() || is_page() ) {
    /*
    Add META tags to Single Page View or Page
    */

    // Custom Field names
    // $desc_fld = “description”;
    // $keyw_fld = “keywords”;

    /*
    Description
    Custom post field “description” overrides post’s excerpt in Single Post View.
    */
    // $desc_fld_content = get_post_meta($posts[0]->ID, $desc_fld, true);
    // if ( !empty($desc_fld_content) ) {
    // If there is a custom field, use it
    // $my_metatags .= “\n“;
    // } elseif ( is_single() ) {
    // Else, use the post’s excerpt. Only for Single Post View (not valid for Pages)
    // $my_metatags .= “\n“;
    // }

    /*
    Keywords
    Custom post field “keywords” overrides post’s categories.
    %cats% is replaced by the post’s categories.
    NOTE: if $include_keywords_in_single_posts is FALSE, then keywords
    metatag is not added to single posts.
    */
    // if ( ($include_keywords_in_single_posts && is_single()) || is_page() ) {
    // $keyw_fld_content = get_post_meta($posts[0]->ID, $keyw_fld, true);
    // if ( !empty($keyw_fld_content) ) {
    // If there is a custom field, use it
    // if ( is_single() ) {
    // For single posts, the %cat% tag is replaced by the post’s categories
    // $keyw_fld_content = str_replace(”%cats%”, amt_get_keywords_from_post_cats(), $keyw_fld_content);
    // }
    // $my_metatags .= “\n“;
    // } elseif ( is_single() ) {
    // Else use only the post’s categories. Only for Single Post View (not valid for Pages)
    // $my_metatags .= “\n“;
    // }
    // }

    // } elseif ( is_home() ) {
    if ( is_home() ) {
    /*
    Add META tags to Home Page
    */

    // Description and Keywords from the options override default behaviour
    $site_description = $options["site_description"];
    $site_keywords = $options["site_keywords"];

    // Description
    if ( empty($site_description) ) {
    // If $site_description is empty, then use the blog description from the options
    $my_metatags .= “\n“;
    } else {
    // If $site_description has been set, then use it in the description meta-tag
    $my_metatags .= “\n“;
    }
    // Keywords
    if ( empty($site_keywords) ) {
    // If $site_keywords is empty, then all the blog’s categories are added as keywords
    $my_metatags .= “\n“;
    } else {
    // If $site_keywords has been set, then these keywords are used.
    $my_metatags .= “\n“;
    }

    } elseif ( is_category() ) {
    /*
    Writes a description META tag only if a description for the current category has been set.
    */

    $cur_cat_desc = category_description();
    if ( $cur_cat_desc ) {
    $my_metatags .= “\n“;
    }
    // Write a keyword metatag if there is a category name (always)
    $cur_cat_name = single_cat_title($prefix = ”, $display = false );
    if ( $cur_cat_name ) {
    $my_metatags .= “\n“;
    }
    }

    if ($my_metatags) {
    echo “\n<!– META Tags added by Add-Meta-Tags WordPress plugin. Get it at: http://www.g-loaded.eu/ –>” . $my_metatags . “\n” . amt_get_site_wide_metatags($site_wide_meta) . “\n\n”;
    }
    }

Lascia un commento

Nome (obbligatorio)

Mail (non sarà pubblicata) (obbligatoria)

Sito web