साइटमैप
वेबसाईट के uploaded content को proper सर्च इंजन मे index करने के लिए साइटमैप का होना बहुत जरूरी है ।
यदि आप वॉर्डप्रेसस के यूजर हैं और आप चाहते है की अपने वेबसाईट मे sitemap.xml फाइल बना कर अपने वॉर्डप्रेसस मे upload कर दें तो आप ऐसा कर सकते है । उसके लिए आप नीचे दिए step को follow करते जाइए –
1 – function.php
आप नीचे दिए हुए कोड को function.php मे patse कर दीजिए
function xml_sitemap() { $postsForSitemap = get_posts(array( 'numberposts' => -1, 'orderby' => 'modified', 'post_type' => array('post','page'), 'order' => 'DESC' )); $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); $sitemap .= '<url>'. '<loc>'. get_permalink($post->ID) .'</loc>'. '</url>'; } $sitemap .= '</urlset>'; $fp = fopen(ABSPATH . "sitemap.xml", 'w'); fwrite($fp, $sitemap); fclose($fp); } add_action("publish_post", "xml_sitemap"); add_action("publish_page", "xml_sitemap"); ?>
या
function xml_sitemap() { $postsForSitemap = get_posts(array( 'numberposts' => -1, 'orderby' => 'modified', 'post_type' => array('post','page'), 'order' => 'DESC' )); $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); $sitemap .= '<url>'. '<loc>'. get_permalink($post->ID) .'</loc>'. '</url>'; } $sitemap .= '</urlset>'; $fp = fopen(ABSPATH . "sitemap.xml", 'w'); fwrite($fp, $sitemap); fclose($fp); } add_action("publish_post", "xml_sitemap"); add_action("publish_page", "xml_sitemap"); ?>
इस तरह से आप बिना plugins के अपने website मे sitemap.xml create कर सकते है ।