FastBots: Ibni Mappa tas-Sit WordPress XML Custom Għat-Taħriġ tal-Bot AI Tiegħek
Martech Zone għandha eluf ta’ artikli, b’ħafna minnhom skaduti. Ħdimt fuq is-sit għal diversi snin biex inneħħi jew naġġorna mijiet ta’ artikli, iżda għad għandi ħafna aktar. Fl-istess ħin, nixtieq inħarreġ bot tal-lingwa naturali bil-kontenut tiegħi, iżda l-aħħar ħaġa li rrid nagħmel hu li nħarreġ fuq artikli skaduti.
FastBots hija Chat GPT-powered bot bennej li inti tista 'tħarreġ inizjalment billi tuża sitemap tiegħek (jew għażliet oħra). Kelli bżonn mappa tas-sit iffiltrata li tinkludi l-artikoli kollha modifikati minn data speċifika. Barra minn hekk, ridt ninkludi l-paġni tiegħi u akronimi (tip ta' post tad-dwana). Ma ridtx ninkludi paġni tal-arkivji għal kategoriji u tikketti jew li jkolli l-home page tiegħi peress li hija wkoll arkivju.
Bl-użu tal-kodiċi li qed nipprovdi fl-aħħar ta 'dan l-artikolu; Bnejt plugin personalizzat WordPress li joħloq custom XML sitemap li jġedded dinamikament kull darba li nippubblika post. FastBots m'għandux metodu ta 'taħriġ mill-ġdid awtomatizzat peress li nippubblika kull artiklu, iżda dan huwa punt ta' tluq kbir għall-użu tal-pjattaforma.
Il-mappa tas-sit timporta l-links kollha biex tħarreġ il- AI Bot fuq:
Il-paġni kollha issa huma importati, u tista 'tħarreġ lill-bot tiegħek fuq id-dejta applikabbli. Għandek ukoll l-opportunità li tneħħi paġni speċifiċi. FastBots ippermettewni wkoll nippersonalizza l-marka tal-bot AI tiegħi u anke ninkludi link għal artiklu rilevanti fit-tweġiba tiegħi. Hemm ukoll talba taċ-ċomb mibnija fil-pjattaforma.
Il-pjattaforma ħadmet bla difetti... tista' tagħti lill-bot tiegħi test drive hawn:
Tnedija Martech Zone's Bot, Marty Ibni l-FastBots AI Bot tiegħek
Custom XML Sitemap
Minflok inżid din il-funzjonalità mat-tema tiegħi, bnejt drawwa WordPress plugin biex tibni Mappa tas-Sit. Żid biss direttorju fil-folder tal-plugins tiegħek, imbagħad a PHP fajl bil-kodiċi li ġej:
<?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');