How to Move Domain Name from PAGE to Post Sitemap in WordPress

Domain Name in Sitemap

WordPress’s default sitemap have domain name in PAGE’s sitemap, If you want to show Homepage/Domain_name in Post’s Sitemap so follow Simple steps –

  • Open cpanel and go to File Manager.
  • Then go to Public_html and Open wp-includes folder.
  • Open Sitemaps folder and then open Providers folder.
  • Open class-wp-sitemaps-posts.php file and change page to post.

Change this highlighted line

if ( 'post' === $post_type && 1 === $page_num && 'posts' === get_option( 'show_on_front' ) ) {
// Extract the data needed for home URL to add to the array.
$sitemap_entry = array(
'loc' => home_url( '/' ),
);

/**
* Filters the sitemap entry for the home page when the 'show_on_front' option equals 'posts'.
*
* @since 5.5.0
*
* @param array $sitemap_entry Sitemap entry for the home page.
*/
$sitemap_entry = apply_filters( 'wp_sitemaps_posts_show_on_front_entry', $sitemap_entry );
$url_list[] = $sitemap_entry;
}

Hope this article helpful for you. If have any questions so contact me via contact us form.