FastBots: Bumuo ng Custom na WordPress XML Sitemap Para sa Pagsasanay sa Iyong AI Bot
Martech Zone ay may libu-libong mga artikulo, na marami sa kanila ay luma na. Nagtrabaho ako sa site sa loob ng ilang taon upang alisin o i-update ang daan-daang mga artikulo, ngunit mayroon pa akong marami pa. Kasabay nito, gusto kong sanayin ang isang natural na bot ng wika sa aking nilalaman, ngunit ang huling bagay na gusto kong gawin ay sanayin ito sa mga lumang artikulo.
FastBots ay isang Chat GPT-powered bot builder na maaari mong sanayin sa simula gamit ang iyong sitemap (o iba pang mga opsyon). Kailangan ko ng na-filter na sitemap na kasama ang lahat ng artikulong binago mula sa isang partikular na petsa. Bukod pa rito, gusto kong isama ang aking mga pahina at akronim (isang pasadyang uri ng post). Hindi ko nais na isama ang mga pahina ng archive para sa mga kategorya at mga tag o magkaroon ng aking home page dahil isa rin itong archive.
Gamit ang code na ibinibigay ko sa dulo ng artikulong ito; Gumawa ako ng custom na WordPress plugin na lumilikha ng custom XML sitemap na dynamic na nagre-refresh sa tuwing mag-publish ako ng post. Ang FastBots ay walang automated retraining method habang inilalathala ko ang bawat artikulo, ngunit ito ay isang magandang panimulang punto para sa paggamit ng platform.
Ini-import ng sitemap ang lahat ng mga link upang sanayin ang AI Bot sa:
Ang lahat ng mga pahina ay na-import na ngayon, at maaari mong sanayin ang iyong bot sa naaangkop na data. May pagkakataon ka ring mag-alis ng mga partikular na page. Pinayagan din ako ng FastBots na i-customize ang pagba-brand ng aking AI bot at kahit na magsama ng link sa isang nauugnay na artikulo sa aking tugon. Mayroon ding isang lead na kahilingan na binuo sa platform.
Ang platform ay gumana nang walang kamali-mali… maaari mong bigyan ang aking bot ng pagsubok dito:
Ilunsad Martech ZoneSi Bot, Marty Buuin ang Iyong FastBots AI Bot
Custom na XML Sitemap
Sa halip na idagdag ang functionality na ito sa aking tema, gumawa ako ng custom WordPress plugin upang bumuo ng isang Sitemap. Magdagdag lamang ng isang direktoryo sa iyong folder ng mga plugin, pagkatapos ay a PHP file na may sumusunod na code:
<?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');