HD Video of How to create sitemap.xml without plugin for WordPress on e akhabaar
It is very important to have a sitemap to index the uploaded content of the website in the proper search engine.
If you are a user of WordPress and you want to create a sitemap.xml file on your website and upload it in your WordPress then you can do so. For that you follow the step given below –
1 – function.php
You patse the following code in function.php
function xml_sitemap() $postsForSitemap = get_posts(array( 'numberposts' => -1, 'orderby' => 'modified', 'post_type' => array('post','page'), 'order' => 'DESC' )); $sitemap = ''; $sitemap .= ''; foreach($postsForSitemap as $post) setup_postdata($post); $sitemap .= ''. ''. get_permalink($post->ID) .' '. ''; $sitemap .= ''; $fp = fopen(ABSPATH . "sitemap.xml", 'w'); fwrite($fp, $sitemap); fclose($fp); add_action("publish_post", "xml_sitemap"); add_action("publish_page", "xml_sitemap"); ?>
or
function xml_sitemap() $postsForSitemap = get_posts(array( 'numberposts' => -1, 'orderby' => 'modified', 'post_type' => array('post','page'), 'order' => 'DESC' )); $sitemap = ''; $sitemap .= ''; foreach($postsForSitemap as $post) setup_postdata($post); $sitemap .= ''. ''. get_permalink($post->ID) .' '. ''; $sitemap .= ''; $fp = fopen(ABSPATH . "sitemap.xml", 'w'); fwrite($fp, $sitemap); fclose($fp); add_action("publish_post", "xml_sitemap"); add_action("publish_page", "xml_sitemap"); ?>
In this way you can create sitemap.xml in your website without plugins.
Give your review about How to create sitemap.xml without plugin for WordPress in Comments below