FastBots: Ngawangun Peta Situs XML Adat WordPress Pikeun Ngalatih Bot AI Anjeun
Martech Zone boga rébuan artikel, kalawan loba di antarana tinggaleun jaman. Kuring geus digawé di loka pikeun sababaraha taun pikeun miceun atawa ngamutahirkeun ratusan artikel, tapi kuring masih boga leuwih loba. Dina waktos anu sami, kuring hoyong ngalatih bot basa alami sareng eusi kuring, tapi anu terakhir anu kuring hoyong laksanakeun nyaéta ngalatih éta dina tulisan anu parantos lami.
FastBots nyaeta Ngobrol GPT-Powered bot pembina nu mimitina anjeun bisa ngalatih maké sitemap anjeun (atawa pilihan séjén). Abdi peryogi sitemap disaring anu kalebet sadaya tulisan anu dirobih saprak tanggal anu khusus. Salaku tambahan, kuring hoyong ngalebetkeun halaman kuring sareng akronim (tipe pos custom). Abdi henteu hoyong ngalebetkeun halaman arsip pikeun kategori sareng tag atanapi gaduh halaman bumi kuring sabab éta ogé arsip.
Ngagunakeun kode Kuring nyadiakeun di ahir artikel ieu; Kuring ngawangun plugin WordPress khusus anu nyiptakeun adat XML sitemap anu dinamis refreshes unggal waktu kuring nyebarkeun pos a. FastBots henteu gaduh metode latihan ulang otomatis nalika kuring nyebarkeun unggal tulisan, tapi ieu mangrupikeun titik awal anu hadé pikeun ngagunakeun platform.
Peta situs ngimpor sadaya tautan pikeun ngalatih AI Bot dina:
Sadaya halaman ayeuna diimpor, sareng anjeun tiasa ngalatih bot anjeun dina data anu lumaku. Anjeun oge boga kasempetan pikeun miceun kaca husus. FastBots ogé ngamungkinkeun kuring pikeun ngaropea branding bot AI kuring sareng kalebet tautan kana tulisan anu relevan dina réspon kuring. Aya ogé pamenta kalungguhan anu diwangun dina platform.
Platformna damel sampurna… anjeun tiasa masihan bot kuring uji drive di dieu:
nyorosodkeun Martech ZoneBot, Marty Bangun FastBots AI Bot Anjeun
Custom XML Sitemap
Tinimbang nambihan fungsionalitas ieu kana téma kuring, kuring ngawangun adat WordPress plugin pikeun ngawangun kaluar Sitemap a. Ngan tambahkeun diréktori dina folder plugins anjeun, teras a PHP file kalawan kode handap:
<?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');