Static Sitemap Generator
Static XML sitemap generation for WordPress with news, image, video sitemaps and WP-CLI.
by Laban The Great · github.com/labanthegreat/static-sitemap-generator · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/labanthegreat/static-sitemap-generator/archive/refs/heads/main.zipGenerates static XML sitemap files on disk instead of building them dynamically on each request. Sitemaps follow the sitemaps.org protocol and are written to the WordPress root directory using the Filesystem API.
Version: 2.0.0 Requires WordPress: 6.0 Requires PHP: 8.0 License: GPL-2.0-or-later
Features
- Writes static
.xmlfiles to disk -- no database queries on crawl requests - Sitemap index with automatic splitting at 50,000 URLs per file
- Per-post-type and per-taxonomy sitemaps
- Author archive sitemaps
- Custom URL entries (one per line, with optional priority and changefreq)
- Google News sitemap (posts from the last 48 hours, filterable by category/tag)
- Google Image sitemap (featured images, galleries, inline content images)
- Google Video sitemap (YouTube/Vimeo detection via oEmbed)
- Hreflang support for WPML and Polylang
- XSL stylesheet for human-readable sitemap viewing in browsers
- Optional gzip-compressed
.xml.gzoutput - Automatic regeneration on content changes (publish, update, delete) with debouncing
- Scheduled regeneration via WP-Cron (hourly, daily, weekly, or disabled)
- Search engine ping (Google, Bing) on sitemap update
- Automatic
robots.txtintegration - Per-post exclusion via meta box (
_ssg_exclude_sitemappost meta) - XML validation against the sitemaps.org XSD schema
- Batched queries (500 posts per batch) to keep memory usage low on large sites
- Full WP-CLI support
Installation
- Upload the
static-sitemap-generatordirectory to/wp-content/plugins/. - Activate through Plugins in the WordPress admin.
- Go to Settings > Sitemap to configure.
On activation, the plugin sets default options, schedules the cron job, and generates an initial sitemap. On uninstall, it removes all generated files, options, post meta, and cron events.
Configuration
The settings page at Settings > Sitemap has the following tabs:
- General -- Post types, taxonomies, author archives, priority/changefreq values, excluded posts, custom URLs, auto-regeneration schedule, search engine ping toggle, XSL stylesheet toggle, hreflang toggle.
- News -- Enable/disable Google News sitemap, publication name, language, category/tag filters.
- Images -- Enable/disable image sitemap generation.
- Videos -- Enable/disable video sitemap generation.
- Advanced -- Gzip compression.
- Status -- Last generation time, URL count, file list, validation results. Includes "Generate Now" and "Validate" buttons.
Individual posts can be excluded from the sitemap using the "Exclude from Sitemap" meta box in the post editor.
WP-CLI Commands
All commands are registered under the wp sitemap namespace.
Generate sitemaps
wp sitemap generate [--type=<type>]
Options:
--type=<type>-- Sitemap type to generate. Acceptsall,standard,news,images,video. Default:all.
# Generate everything
wp sitemap generate
# Generate only the news sitemap
wp sitemap generate --type=news
# Generate only the standard post/taxonomy/author sitemaps
wp sitemap generate --type=standard
Show status
wp sitemap status
Displays last generation time, total URLs, file count, sitemap URL, last ping time, and total file size.
List generated files
wp sitemap list [--format=<format>]
Options:
--format=<format>-- Output format. Acceptstable,csv,json. Default:table.
wp sitemap list
wp sitemap list --format=json
Validate sitemaps
wp sitemap validate
Runs XML well-formedness checks, XSD schema validation, URL count/file size limit checks, W3C date format validation, and cross-file duplicate URL detection.
Ping search engines
wp sitemap ping
Sends ping requests to Google and Bing (and any endpoints added via the ssg_ping_endpoints filter).
Remove generated files
wp sitemap clean [--yes]
Deletes all generated sitemap files and clears stored metadata. Prompts for confirmation unless --yes is passed.
Hooks and Filters
Filters
ssg_included_post_types
Modify the list of post types included in the sitemap.
add_filter( 'ssg_included_post_types', function ( array $post_types ): array {
$post_types[] = 'product';
return $post_types;
} );
ssg_included_taxonomies
Modify the list of taxonomies included in the sitemap.
add_filter( 'ssg_included_taxonomies', function ( array $taxonomies ): array {
return array_diff( $taxonomies, array( 'post_tag' ) );
} );
ssg_post_type_query_args
Modify the WP_Query arguments used when querying posts for a given post type.
add_filter( 'ssg_post_type_query_args', function ( array $args, string $post_type ): array {
if ( 'post' === $post_type ) {
$args['date_query'] = array( array( 'after' => '1 year ago' ) );
}
return $args;
}, 10, 2 );
ssg_post_type_urls
Filter the final URL entries array for a post type sitemap before it is written to disk.
add_filter( 'ssg_post_type_urls', function ( array $urls, string $post_type ): array {
// Modify entries as needed.
return $urls;
}, 10, 2 );
ssg_taxonomy_urls
Filter URL entries for a taxonomy sitemap.
add_filter( 'ssg_taxonomy_urls', function ( array $urls, string $taxonomy ): array {
return $urls;
}, 10, 2 );
ssg_author_urls
Filter URL entries for the author sitemap.
ssg_custom_urls
Filter custom URL entries parsed from the settings textarea.
ssg_hreflang_entries
Filter hreflang alternate link entries for a specific post.
add_filter( 'ssg_hreflang_entries', function ( array $entries, int $post_id ): array {
return $entries;
}, 10, 2 );
ssg_ping_endpoints
Modify or add search engine ping endpoints.
add_filter( 'ssg_ping_endpoints', function ( array $endpoints, string $sitemap_url ): array {
$endpoints['yandex'] = 'https://blogs.yandex.ru/pings/?status=success&url=' . rawurlencode( $sitemap_url );
return $endpoints;
}, 10, 2 );
ssg_robots_sitemap_lines
Filter the sitemap directive lines appended to robots.txt.
add_filter( 'ssg_robots_sitemap_lines', function ( array $lines, array $options ): array {
return $lines;
}, 10, 2 );
Actions
ssg_after_ping
Fires after search engine ping requests complete. Receives the results array keyed by engine name.
add_action( 'ssg_after_ping', function ( array $results ): void {
// Log or notify.
} );
Post Meta
_ssg_exclude_sitemap-- Set to1on a post to exclude it from the sitemap. Managed via the meta box in the post editor.
Custom URLs Format
In the settings textarea, enter one URL per line. Optionally append priority and change frequency separated by pipes:
https://example.com/custom-page|0.7|weekly
https://example.com/another-page
If omitted, priority defaults to 0.5 and changefreq defaults to monthly.
Generated Files
All files are written to the WordPress root directory (ABSPATH):
sitemap.xml-- Sitemap index referencing all sub-sitemapssitemap-{post_type}.xml-- Per-post-type sitemaps (split with-2,-3suffixes if exceeding 50,000 URLs)sitemap-tax-{taxonomy}.xml-- Per-taxonomy sitemapssitemap-authors.xml-- Author archive sitemapsitemap-custom.xml-- Custom URLs sitemapsitemap-news.xml-- Google News sitemapsitemap-images.xml-- Image sitemapsitemap-video.xml-- Video sitemapsitemap-style.xsl-- XSL stylesheet for browser viewing
Screenshots
General tab with content type selection, taxonomy toggles, author archives, and post exclusion
News sitemap tab with Google News configuration, publication name, and category filters
Status tab with generation stats, sitemap URL, ping results, and sitemap index tree
Priority and change frequency configuration per content type
Changelog
2.0.0
- Batched post queries with configurable batch size (500) for large sites
- Automatic sitemap splitting at the 50,000 URL protocol limit
- XMLWriter-based streaming output to reduce memory usage
- Google News, Image, and Video sitemap support
- Hreflang support for WPML and Polylang
- Gzip compression option
- XSD schema validation and sitemap validator
- WP-CLI commands: generate, status, list, validate, ping, clean
- Debounced content change detection with deferred regeneration
- Custom URL support with priority and changefreq
- XSL stylesheet for human-readable sitemap viewing
- AJAX-based generate and validate from the admin settings page
1.0.0
- Initial release
- Static XML sitemap generation for posts, pages, taxonomies, and authors
- Automatic regeneration on content changes
- Search engine ping (Google, Bing)
- Robots.txt integration
- Per-post sitemap exclusion
Author
Laban The Great
- Web: labanthegreat.com
- GitHub: github.com/labannjoroge