What is sitemap?
A sitemap is where you give data about the pages, recordings, and different documents on your site, and the connections between them. Web indexes like Google read this document to all the more astutely slither your website.
A sitemap reveals to Google which pages and documents you believe are significant in your site, and furthermore gives important data about these records: for instance, for pages, when the page was last refreshed, how frequently the page is changed, and any other language adaptations of a page.
How to create in wordpress?
WordPress has similar structure if you are running a blog and you need to listed category and post in sitemap. If you will go for free tool you will get limited url indexed in sitemap. However you want to create sitemap , You have to include wp-blog-header.php as per your located file. It will allow you to access wordpress DB connection. For example :
I have placed a file https://www.coodingdessign.com/ over root folder and allowed
include (‘/var/www/html/’ . $file . ‘/wp-blog-header.php’);
//$file means your root path which might be different
1.Add categories to sitemap first
There are two types to add category pages , You may pick from database then can create url then added to sitemap , Else you can scrap data from live url which will return complete url of category as i have followed second way. For which i have added a http.php client library to get content and it will return all url containing categories.
2. Add to all post urls to sitemap
Being a wordpress developer as you know all post saved in wp_posts table over there you can see guid column. You need to fetch all post and add to sitemap.
3.How to create structure for sitemap
To create structure and get best crawling you need to require four fields:
Loc means your category/page/post URL which needs to be crawl
Change Freq will depicts timely updated data
Last mode as it’s say last modification of your page/post
Priority mean which url need to be highly crawled
You can generate sitemap you have wordpress knowledge or not. There are two parameter one as $file which means your domain name. Another is $ishttp that means your site is SSL secure or not .
$ishttp = 1 or 0;
To get complete code please visit here: Github