A sitemap can help search engines find your important pages, but you may not need another plugin to create one. Modern WordPress sites already include a built-in XML sitemap that works as soon as your site is live.

That means fewer updates, fewer settings, and one less tool competing for control of your SEO. We’ll show you where to find your sitemap, how to check what it contains, when custom code makes sense, and how to submit it to Google.

Key Takeaways

  • WordPress automatically creates a sitemap at /wp-sitemap.xml.
  • You can control which content appears by adjusting WordPress visibility settings.
  • A custom PHP sitemap is possible, but most small websites don’t need one.
  • Submit the sitemap index to Google Search Console after testing it.
  • Reliable hosting keeps the sitemap available when search engines request it.

WordPress Already Creates a Sitemap

Since WordPress 5.5, the WordPress core software has generated XML sitemaps without an SEO plugin. The main sitemap address is:

https://yourdomain.com/wp-sitemap.xml

Replace yourdomain.com with your real domain name. If WordPress is installed in a subfolder, include that folder in the address.

For example, a site at example.com would use:

https://example.com/wp-sitemap.xml

Open the address in your browser. You should see a sitemap index with links to smaller sitemap files, such as post, page, author, or category sitemaps. This structure helps WordPress handle sites with more content without placing every URL in one huge file.

The official WordPress sitemap documentation explains which content types WordPress includes by default. In general, WordPress adds publicly visible content that search engines can access. Private posts, drafts, password-protected content, and content types blocked from public viewing shouldn’t appear.

This is the important part: you don’t have to create an XML file by hand for a standard WordPress website. Core WordPress does the work and updates the sitemap as you publish or change content.

A sitemap also isn’t a ranking shortcut. It tells search engines which URLs matter to you. Google still decides whether to crawl, index, and rank those pages based on quality, accessibility, links, and search intent. Think of the sitemap as a clear site map, not a VIP pass.

If the sitemap doesn’t load, check the basics first:

  1. Confirm that your website is publicly accessible.
  2. Go to Settings > Reading and make sure search engine visibility isn’t blocking the site.
  3. Visit Settings > Permalinks, then click Save Changes.
  4. Clear your caching system and test /wp-sitemap.xml again.

Saving the permalink settings refreshes WordPress rewrite rules. That one quick step fixes many sitemap address errors.

Check What Your WordPress XML Sitemap Includes

Creating a sitemap is only half the job. We also need to check whether it contains useful URLs.

Open the sitemap index and follow each child sitemap. Look for pages that should appear in search, including:

  • Published blog posts
  • Important pages such as Services, About, and Contact
  • Public custom post types
  • Public taxonomies, if they contain useful archive pages

Then watch for URLs that shouldn’t be there. Thin tag archives, test pages, duplicate author pages, and outdated content can make the sitemap less helpful.

WordPress core doesn’t offer a full sitemap control panel. That’s one reason some website owners install an SEO plugin. But a plugin isn’t required if your site has a straightforward structure.

We can control sitemap content through WordPress settings and code. Start with the public visibility of each content type. A post type that isn’t publicly queryable generally won’t belong in the sitemap. The same applies to taxonomies that aren’t public.

Avoid blocking important pages in robots.txt while expecting the sitemap to make them visible. Google’s robots.txt guidance explains how crawl restrictions work. A URL listed in a sitemap but blocked from crawling sends mixed instructions.

A sitemap should contain your best, indexable URLs, not every URL your site can produce.

We should also check the quality of each listed page. Does it load normally? Does it show a 200 status code? Does the canonical URL point to itself? Is the page useful enough to deserve search traffic?

A sitemap can’t repair broken pages, redirect chains, or duplicate content. It only reports the URLs WordPress has chosen to publish.

The XML Sitemap protocol supports elements such as <loc> and <lastmod>. WordPress generates these values for its own sitemap files. We don’t need to add priority scores or change frequency values. Google has said those older optional hints don’t drive crawling decisions in the way many site owners expect.

Build a Custom Sitemap With PHP

Most small business websites should use the built-in WordPress sitemap. A custom sitemap makes sense when we need a special URL set, a custom endpoint, or a sitemap that includes only selected content.

Before adding code, remember that custom sitemap code creates another system to maintain. A mistake can produce invalid XML, expose the wrong URLs, or stop working after a theme change.

The following example creates a separate sitemap at /custom-sitemap.xml. It includes published posts and pages, then adds the last modified date for each URL.

Add it to a child theme’s functions.php file or a site-specific code plugin. A child theme is safer than editing the main theme because theme updates can overwrite changes.

add_action('init', function () {
    add_rewrite_rule(
        '^custom-sitemap.xml$',
        'index.php?custom_sitemap=1',
        'top'
    );
});


add_filter('query_vars', function ($vars) {
    $vars[] = 'custom_sitemap';
    return $vars;
});


add_action('template_redirect', function () {
    if (!get_query_var('custom_sitemap')) {
        return;
    }


    $posts = get_posts([
        'post_type'      => ['post', 'page'],
        'post_status'    => 'publish',
        'posts_per_page' => -1,
        'orderby'        => 'modified',
        'order'          => 'DESC',
        'no_found_rows'  => true,
    ]);


    header('Content-Type: application/xml; charset=UTF-8');


    echo '<?xml version="1.0" encoding="UTF-8"?>';
    echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';


    foreach ($posts as $post) {
        echo '<url>';
        echo '<loc>' . esc_url(get_permalink($post)) . '</loc>';
        echo '<lastmod>' . esc_html(
            get_post_modified_time('c', true, $post)
        ) . '</lastmod>';
        echo '</url>';
    }


    echo '</urlset>';
    exit;
});

After adding the code, go to Settings > Permalinks and click Save Changes. You don’t need to change the permalink structure. This refreshes the rewrite rule so WordPress recognizes the new address.

Now visit:

https://yourdomain.com/custom-sitemap.xml

For a small website, this can work well. For a large site, it’s not the right pattern because posts_per_page => -1 loads every matching post at once. Large websites should use paginated sitemap files and a sitemap index, or stay with the WordPress core system.

Don’t replace /wp-sitemap.xml unless you have a strong reason. The core sitemap already handles multiple files and updates itself. A custom file should solve a clear problem, not create another maintenance task.

Submit the Sitemap to Google

Once the sitemap loads and contains the right URLs, submit it to Google Search Console.

Add and verify your website property first. Then open Sitemaps in the left-hand menu. Enter only the sitemap path:

wp-sitemap.xml

Click Submit. Google will fetch the sitemap index and inspect the child sitemap files linked inside it.

Google’s sitemap submission guidance makes one point clear: submitting a sitemap doesn’t guarantee that every URL will be indexed. It gives Google a useful list of pages to crawl.

You can also reference the sitemap in your robots.txt file:

Sitemap: https://yourdomain.com/wp-sitemap.xml

Place that line in the root robots.txt file if you manage it manually. Many WordPress sites can display a virtual robots file automatically, so check the current version before making changes.

After submission, Search Console may show statuses such as Success, Couldn’t fetch, or Has errors. A successful fetch means Google accessed the file. It doesn’t mean every URL passed indexing checks.

Give Google time to process the sitemap. Check the report again after new content has been published or after fixing a technical problem.

Fix Common Sitemap Problems

A sitemap error usually has a simple cause. We can narrow it down quickly.

The sitemap shows a 404 error. Save the permalink settings, clear caches, and test again. If the problem remains, another plugin, theme function, or server rule may be disabling WordPress sitemaps.

The sitemap is blocked. Review security tools, firewall rules, maintenance mode, and password protection. Search engine crawlers need to access the sitemap without logging in.

Google reports invalid XML. Look for custom code that prints extra characters, warnings, or blank lines before the XML declaration. PHP errors can corrupt an otherwise valid sitemap.

Important pages are missing. Check whether the content is published and publicly queryable. Review post type settings, taxonomy visibility, and any filters added to the site.

The sitemap contains redirected or deleted URLs. Remove stale custom code and clear caching layers. The built-in sitemap should update after content changes, but aggressive caching can continue showing an old response.

Hosting affects all of this. If the server regularly times out, blocks crawlers, or serves slow PHP responses, even a correctly configured sitemap can fail. ZADiC WordPress hosting includes one-click setup, free SSL on many plans, security monitoring, and 24/7 human support, so we can spend less time fixing server issues and more time improving the site.

Conclusion

For most WordPress websites, creating an XML sitemap without a plugin takes only a few minutes because WordPress already generates one. We need to confirm /wp-sitemap.xml works, review the URLs, and submit the sitemap index to Google.

Custom PHP is available when a site needs a separate, carefully controlled sitemap. Otherwise, the built-in WordPress system is the cleaner choice. With dependable hosting behind it, your sitemap stays available while you focus on publishing useful pages and growing your business.

We use cookies so you can have a great experience on our website. View more
Cookies settings
Accept
Decline
Privacy & Cookie policy
Privacy & Cookies policy
Cookie name Active

Who we are

Our website address is: https://zadic.net.

Comments

When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection. An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.

Cookies

If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year. If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser. When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed. If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website. These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue. For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Visitor comments may be checked through an automated spam detection service.
Save settings
Cookies settings