FastBots: Adeiladu Map Safle XML WordPress Custom Ar gyfer Hyfforddi Eich Bot AI

Martech Zone Mae ganddi filoedd o erthyglau, gyda llawer ohonynt yn hen ffasiwn. Rwyf wedi gweithio ar y wefan ers sawl blwyddyn i ddileu neu ddiweddaru cannoedd o erthyglau, ond mae gen i lawer mwy o hyd. Ar yr un pryd, hoffwn hyfforddi bot iaith naturiol gyda fy nghynnwys, ond y peth olaf rydw i eisiau ei wneud yw ei hyfforddi ar erthyglau hen ffasiwn.

FastBots yn SgwrsGPT-adeiladwr bot wedi'i bweru y gallwch chi ei hyfforddi i ddechrau gan ddefnyddio'ch map gwefan (neu opsiynau eraill). Roeddwn angen map gwefan wedi'i hidlo a oedd yn cynnwys yr holl erthyglau a addaswyd ers dyddiad penodol. Yn ogystal, roeddwn i eisiau cynnwys fy nhudalennau a acronymau (math post arferol). Doeddwn i ddim eisiau cynnwys tudalennau archif ar gyfer categorïau a thagiau na chael fy nhudalen gartref gan ei fod hefyd yn archif.

Gan ddefnyddio'r cod rwy'n ei ddarparu ar ddiwedd yr erthygl hon; Adeiladais ategyn WordPress wedi'i deilwra sy'n creu arferiad XML map gwefan sy'n adnewyddu'n ddeinamig bob tro y byddaf yn cyhoeddi post. Nid oes gan FastBots ddull ailhyfforddi awtomataidd gan fy mod yn cyhoeddi pob erthygl, ond mae hwn yn fan cychwyn gwych ar gyfer defnyddio'r platfform.

Mae'r map gwefan yn mewnforio'r holl ddolenni i hyfforddi'r AI Bot ar:

Mae pob tudalen bellach wedi'i mewnforio, a gallwch hyfforddi'ch bot ar y data perthnasol. Mae gennych hefyd gyfle i ddileu tudalennau penodol. Roedd FastBots hefyd yn caniatáu imi addasu brandio fy bot AI a hyd yn oed gynnwys dolen i erthygl berthnasol yn fy ymateb. Mae yna hefyd gais arweiniol wedi'i ymgorffori yn y platfform.

Gweithiodd y platfform yn ddi-ffael ... gallwch chi roi prawf gyrru i'm bot yma:

Lansio Martech Zone's Bot, Marty Adeiladu Eich FastBots AI Bot

Map Safle Custom XML

Yn hytrach nag ychwanegu'r swyddogaeth hon at fy thema, fe wnes i adeiladu arferiad WordPress ategyn i adeiladu Map Safle. Ychwanegwch gyfeiriadur yn eich ffolder ategion, yna a PHP ffeil gyda'r cod canlynol:

<?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');
Allanfa fersiwn symudol