人工智能內容營銷營銷工具

FastBots:建立自訂 WordPress XML 網站地圖來訓練您的 AI 機器人

Martech Zone 有數千篇文章,其中許多已經過時。 我在該網站上工作了幾年,刪除或更新了數百篇文章,但我還有更多文章。 同時,我想用我的內容訓練一個自然語言機器人,但我最不想做的就是在過時的文章上訓練它。

快速機器人 ChatGPT- 驅動的機器人建構器,您可以使用網站地圖(或其他選項)進行初始訓練。 我需要一個經過篩選的網站地圖,其中包含自特定日期以來修改的所有文章。 此外,我想包括我的頁面和 首字母縮寫詞 (自訂貼文類型)。 我不想包含類別和標籤的存檔頁面或擁有我的主頁,因為它也是一個存檔。

使用我在本文末尾提供的程式碼; 我建立了一個自訂 WordPress 外掛程式來建立自訂 XML的 每次我發布帖子時都會動態刷新網站地圖。 當我發布每篇文章時,FastBots 沒有自動重新訓練方法,但這是使用該平台的一個很好的起點。

網站地圖導入所有連結來訓練 AI 機器人上:

FastBots:從您網站的網站地圖訓練機器人。

所有頁面現已匯入,您可以根據適用的資料訓練您的機器人。 您也可以刪除特定頁面。 FastBots 還允許我自訂 AI 機器人的品牌,甚至在我的回覆中包含相關文章的連結。 該平台還內建了潛在客戶請求。

該平台運行完美…您可以在這裡試駕我的機器人:

發佈會 Martech Zone的機器人,馬蒂 建立您的 FastBots 人工智慧機器人

自訂 XML 網站地圖

我沒有將此功能添加到我的主題中,而是建立了一個自訂 WordPress 用於建立網站地圖的插件。 只需在插件資料夾中新增一個目錄,然後 PHP 帶有以下代碼的文件:

<?php
/*
Plugin Name: Bot Sitemap
Description: Dynamically generates an XML sitemap including posts modified since a specific date and updates it when a new article is added.
Version: 1.0
Author: Your Name
*/

// Define the date since when to include modified posts (format: Y-m-d)
$mtz_modified_since_date = '2020-01-01';

// Register the function to update the sitemap when a post is published
add_action('publish_post', 'mtz_update_sitemap_on_publish');

// Function to update the sitemap
function mtz_update_sitemap_on_publish($post_id) {
    // Check if the post is not an auto-draft
    if (get_post_status($post_id) != 'auto-draft') {
        mtz_build_dynamic_sitemap();
    }
}

// Main function to build the sitemap
function build_bot_sitemap() {
    global $mtz_modified_since_date;

    $args = array(
        'post_type' => 'post',
        'date_query' => array(
            'column' => 'post_modified',
            'after'  => $mtz_modified_since_date
        ),
        'posts_per_page' => -1 // Retrieve all matching posts
    );

    $postsForSitemap = get_posts($args);

    // Fetch all 'acronym' custom post type posts
    $acronymPosts = get_posts(array(
        'post_type' => 'acronym',
        'posts_per_page' => -1,
    ));

    // Fetch all pages except the home page
    $pagesForSitemap = get_pages();
    $home_page_id = get_option('page_on_front');

    $sitemap = '<?xml version="1.0" encoding="UTF-8"?>';
    $sitemap .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

    foreach($postsForSitemap as $post) {
        setup_postdata($post);
        if ($post->ID != $home_page_id) {
            $sitemap .= '<url>'.
                          '<loc>'. get_permalink($post) .'</loc>'.
                          '<lastmod>'. get_the_modified_date('c', $post) .'</lastmod>'.
                          '<changefreq>weekly</changefreq>'.
                        '</url>';
        }
    }

    foreach($acronymPosts as $post) {
        setup_postdata($post);
        if ($post->ID != $home_page_id) {
            $sitemap .= '<url>'.
                          '<loc>'. get_permalink($post) .'</loc>'.
                          '<lastmod>'. get_the_modified_date('c', $post) .'</lastmod>'.
                          '<changefreq>weekly</changefreq>'.
                        '</url>';
        }
    }

    foreach($pagesForSitemap as $page) {
        setup_postdata($page);
        if ($page->ID != $home_page_id) {
            $sitemap .= '<url>'.
                          '<loc>'. get_permalink($page) .'</loc>'.
                          '<lastmod>'. get_the_modified_date('c', $page) .'</lastmod>'.
                          '<changefreq>monthly</changefreq>'.
                        '</url>';
        }
    }

    wp_reset_postdata();

    $sitemap .= '</urlset>';

    file_put_contents(get_home_path().'bot-sitemap.xml', $sitemap);
}

// Activate the initial sitemap build on plugin activation
register_activation_hook(__FILE__, 'build_bot_sitemap');

Douglas Karr

Douglas Karr 是 CMO 的 開放洞察 和創始人 Martech Zone。 道格拉斯幫助了數十家成功的 MarTech 新創公司,協助進行了超過 5 億美元的 MarTech 收購和投資盡職調查,並繼續協助公司實施和自動化其銷售和行銷策略。 道格拉斯是國際公認的數位轉型和 MarTech 專家和演講者。 道格拉斯也是一本傻瓜指南和一本商業領導書的出版作者。

相關文章

返回頂部按鈕
關閉

檢測到Adblock

Martech Zone 我們能夠免費為您提供這些內容,因為我們通過廣告收入、聯屬鏈接和讚助從我們的網站中獲利。 如果您在瀏覽我們的網站時刪除廣告攔截器,我們將不勝感激。