FastBots: Tsim Kev Cai WordPress XML Sitemap Rau Kev Kawm Koj AI Bot
Martech Zone muaj ntau txhiab kab lus, nrog ntau ntawm lawv outdated. Kuv tau ua haujlwm ntawm lub xaib tau ntau xyoo los tshem tawm lossis hloov kho ntau pua cov ntawv, tab sis kuv tseem muaj ntau ntxiv. Nyob rau tib lub sijhawm, kuv xav cob qhia ib hom lus bot nrog kuv cov ntsiab lus, tab sis qhov kawg kuv xav ua yog cob qhia nws ntawm cov ntawv tshaj tawm.
FastBots yog ib tug Sib tham GPT-powered bot builder uas koj tuaj yeem pib qhia siv koj daim ntawv qhia chaw (lossis lwm yam kev xaiv). Kuv xav tau daim ntawv qhia chaw lim dej uas suav tag nrho cov ntawv hloov kho txij li hnub tshwj xeeb. Tsis tas li ntawd, kuv xav suav nrog kuv nplooj ntawv thiab cov ntawv acrony (ib hom kev cai tshaj tawm). Kuv tsis xav kom suav nrog cov nplooj ntawv khaws tseg rau pawg thiab cov cim npe lossis muaj kuv lub tsev nplooj ntawv vim nws tseem yog archive.
Siv cov cai kuv muab rau hauv qhov kawg ntawm tsab xov xwm no; Kuv tsim ib qho kev cai WordPress plugin uas tsim kev cai XML sitemap uas dynamically refreshes txhua zaus kuv tshaj tawm ib tug ncej. FastBots tsis muaj txoj hauv kev automated retraining raws li kuv tshaj tawm txhua tsab xov xwm, tab sis qhov no yog qhov pib zoo rau kev siv lub platform.
Lub sitemap imports tag nrho cov txuas mus cob qhia AI Bot ntawm:
Tag nrho cov nplooj ntawv tam sim no raug xa mus, thiab koj tuaj yeem cob qhia koj bot ntawm cov ntaub ntawv siv tau. Koj kuj muaj sijhawm los tshem tawm cov nplooj ntawv tshwj xeeb. FastBots kuj tau tso cai rau kuv hloov kho kuv tus AI bot lub npe thiab txawm tias muaj qhov txuas mus rau ib tsab xov xwm cuam tshuam hauv kuv cov lus teb. Kuj tseem muaj kev thov ua tus thawj coj ua rau hauv lub platform.
Lub platform ua haujlwm flawlessly… koj tuaj yeem muab kuv tus bot sim tsav ntawm no:
Tua tawm Martech Zone's Bot, Marty Tsim koj FastBots AI Bot
Custom XML Sitemap
Es tsis ntxiv qhov kev ua haujlwm no rau kuv lub ntsiab lus, kuv tau tsim kev cai WordPress plugin los tsim ib lub Sitemap. Tsuas yog ntxiv cov npe hauv koj lub plugins folder, ces a PHP file nrog cov cai hauv qab no:
<?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');