• Having looked at the Google Sitemap Generator 3.0b documentation, it mentions that you can add your own code to automatically add new URLs to the sitemap. UltimateTagWarrior (UTW3) populates a tag table with its own tag names, and I would like to automatically add all these tags into the sitemap, e.g.

    https://www.dicontas.co.uk/blog/index.php?tag=tagname1
    https://www.dicontas.co.uk/blog/index.php?tag=tagname2

    I have created the code, but I do not know where to put this? Do I add my code to the sitemap.php file, and if so where? If not, what file do I create and how do I call this when GSG executes from the Admin panel?

    My code is as follows – anyone is free to use/modify it as they see fit…

    /**
    * Retrieves the tags from UTW - Author : Stewart Farquhar
    */
    function GetUTWtags() {
    $utwtagObject = &GoogleSitemapGenerator::GetInstance(); //Please note the "&" sign!
    $utwtags=array();
    //Query UTW tags table and add them into the array
    $utwtags=$wpdb->get_results("SELECT
    tags FROM ” . $wpdb->tags . “");
    if($utwtags) {
    foreach($utwtags as $utwtag) {
    $utw_tag = "https://www.dicontas.co.uk/blog/index.php?tag=" . $utwtag->tag;
    if($utwtagObject!=null) $utwtagObject->AddUrl($utw_tag,time(),"daily",0.6);
    }
    }
    }
    add_action("sm_buildmap","GetUTWtags");

    Can anyone please assist?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    create a new PHP file and put it in the wp-content/plugins folder. I’ve corrected your code a little bit, it should work after you activated this plugin at the plugin screen.


    <?php
    /*
    Plugin Name: UTF with Google Sitemaps
    */
    function GetUTWtags() {
    global $wpdb,$table_prefix;
    $utwtagObject = &GoogleSitemapGenerator::GetInstance(); //Please note the "&" sign!
    $utwtags=array();
    //Query UTW tags table and add them into the array
    $utwtags=$wpdb->get_results("SELECT tag FROM " . $table_prefix . "tags" . "");
    if($utwtags) {
    foreach($utwtags as $utwtag) {
    $utw_tag = "https://www.dicontas.co.uk/blog/index.php?tag=" . $utwtag->tag;
    if($utwtagObject!=null) $utwtagObject->AddUrl($utw_tag,time(),"daily",0.6);
    }
    }
    }
    add_action("sm_buildmap","GetUTWtags");
    ?>

    Best regards,

    Arne

    Thread Starter spfarquhar

    (@spfarquhar)

    Thanks Arne,

    I have taken this plugin and added it to the WordPress WP-Plugins under Metadata->Tag Plugins list.

    It is named:
    Google Sitemaps – UTW Tag Addon

    and located at:
    https://wp-plugins.net/plugin/UTWgoogleSitemaps/

    My plugin page is:
    https://www.dicontas.co.uk/blog/google-sitemap-utw-tag-wordpress-plugin/

    Hope this helps all UltimateTagWarrior (UTW) and Google Sitemap (GS) plugin owners. I was fed up manually adding all the UTW tag URL pages into the Sitemap as new tags are created by me all the time, and as Arne (the GS author) added a new feature to automate this process, I creating this new plugin to cancel out this manual work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding UTW tags to Google Sitemap Generator 3.0b’ is closed to new replies.