{"id":13566695,"url":"https://github.com/Automattic/msm-sitemap","last_synced_at":"2025-04-04T00:31:59.447Z","repository":{"id":7555157,"uuid":"8908413","full_name":"Automattic/msm-sitemap","owner":"Automattic","description":"Comprehensive sitemaps for your WordPress VIP site. Joint collaboration between Metro.co.uk, WordPress VIP, Alley Interactive, Maker Media, 10up, and others.","archived":false,"fork":false,"pushed_at":"2024-08-22T22:22:36.000Z","size":440,"stargazers_count":73,"open_issues_count":37,"forks_count":37,"subscribers_count":123,"default_branch":"main","last_synced_at":"2024-10-08T11:16:58.210Z","etag":null,"topics":["vip","wordpress","wordpress-plugin","wpvip-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Automattic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-03-20T16:01:25.000Z","updated_at":"2024-09-16T23:10:35.000Z","dependencies_parsed_at":"2023-11-15T22:40:32.154Z","dependency_job_id":"be00a39d-8899-4c35-bdc5-931ae9bc9117","html_url":"https://github.com/Automattic/msm-sitemap","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fmsm-sitemap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fmsm-sitemap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fmsm-sitemap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fmsm-sitemap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Automattic","download_url":"https://codeload.github.com/Automattic/msm-sitemap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223075364,"owners_count":17083505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["vip","wordpress","wordpress-plugin","wpvip-plugin"],"created_at":"2024-08-01T13:02:14.821Z","updated_at":"2024-11-04T21:30:49.489Z","avatar_url":"https://github.com/Automattic.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"Comprehensive Sitemaps\n===========\n\nComprehensive sitemaps for your WordPress VIP site. Site-wide sitemaps on WordPress.com includes 1,000 entries by default. This plugin allows you to include all the entries on your site into your sitemap.\n\nJoint collaboration between Metro.co.uk, WordPress.com VIP, Alley Interactive, Maker Media, 10up, and others.\n\n## How It Works\n\n### Sitemap Data Storage\n\n* One post type entry for each date.\n* Sitemap XML is generated and stored in meta. This has several benefits:\n * Avoid memory and timeout problems when rendering heavy sitemap pages with lots of posts.\n * Older archives that are unlikely to change can be served up faster since we're not building them on-demand.\n* Archive pages are rendered on-demand.\n\n### Sitemap Generation\n\nWe want to generate the entire sitemap catalogue async to avoid running into timeout and memory issues.\n\nHere's how the default WP-Cron approach works:\n\n* Get year range for content.\n* Store these years in options table.\n* Kick off a cron event for the first year.\n* Calculate the months to process for that year and store in an option.\n* Kick off a cron event for the first month in the year we're processing.\n* Calculate the days to process for that year and store in an option.\n* Kick off a cron event for the first day in the month we're processing.\n* Generate the sitemap for that day.\n* Find the next day to process and repeat until we run out of days.\n* Move on to the next month and repeat.\n* Move on to next year when we run out of months.\n\nThe Comprehensive Sitemap plugin will only update the standard sitemap. The [news sitemap ](https://en.support.wordpress.com/sitemaps/#news-sitemaps) will only contain posts from the last two days, based on [Google’s guidelines](https://support.google.com/news/publisher/answer/74288?hl=en).\n\n## CLI Commands\n\nThe plugin ships with a bunch of wp-cli commands to simplify sitemap creation:\n\n```\n$ wp msm-sitemap\nusage: wp msm-sitemap generate-sitemap\n   or: wp msm-sitemap generate-sitemap-for-year\n   or: wp msm-sitemap generate-sitemap-for-year-month\n   or: wp msm-sitemap generate-sitemap-for-year-month-day\n   or: wp msm-sitemap recount-indexed-posts\n\nSee 'wp help msm-sitemap \u003ccommand\u003e' for more information on a specific command.\n```\n\n## Custom post types\n\nInclude custom post types in the generated sitemap with the `msm_sitemap_entry_post_type` filter.\n\n## Generate Sitemap with posts of a custom status other than 'publish'\n\nBy default, the sitemap will only fetch posts with the status of 'publish'. To change this, use the `msm_sitemap_post_status` filter.\n\n```\nfunction example_filter_msm_sitemap_post_status( $post_status ) {\n    return 'my_custom_status';\n}\nadd_filter( 'msm_sitemap_post_status', 'example_filter_msm_sitemap_post_status', 10, 1 );\n```\n\n## Filtering Sitemap URLs\n\nIf you need to filter the URLs displayed in a sitemap created via the Comprehensive Sitemap plugin, there are two considerations. First, if you are filtering the individual sitemaps, which display the URLs to the articles published on a specific date, you can use the `msm_sitemap_entry` hook to filter the URLs. An example for a reverse-proxy situation is below:\n\n```\nfunction example_filter_msm_sitemap_entry( $url ) {\n    $location = str_replace( 'example.wordpress.com', 'example.com/blog', $url-\u003eloc );\n    $url-\u003eloc = $location;\n    return $url;\n}\nadd_filter( 'msm_sitemap_entry', 'example_filter_msm_sitemap_entry', 10, 1 );\n```\n\nSecond, if you are filtering the root sitemap, which displays the URLs to the individual sitemaps by date, you will need to filter the `home_url` directly. There is no plugin-specific hook to filter the URLs on the root sitemap.\n\n\n## Filter Sitemap Index\n\nUse the `msm_sitemap_index` filter to exclude daily sitemaps from the index based on date.\n\n```\nadd_filter( 'msm_sitemap_index', function( $sitemaps ) {\n    $reference_date = strtotime( '2017-09-09' );\n\n    return array_filter( $sitemaps, function ( $date ) use ( $reference_date ) {\n        return ( $reference_date \u003c strtotime( $date ) );\n    } );\n} );\n```\n\n## Customize the last modified posts query\n\nUse the `msm_pre_get_last_modified_posts` filter to customize the query that gets the last modified posts.\n\nOn large sites, this filter could be leveraged to enhance query efficiency by avoiding scanning older posts that don't get updated frequently and making better use of the `type_status_date` index.\n\n```\nfunction ( $query, $post_types_in, $date ) {\n    global $wpdb;\n\n    $query = $wpdb-\u003eprepare( \"SELECT ID, post_date FROM $wpdb-\u003eposts WHERE post_type IN ( {$post_types_in} ) AND post_status = 'publish' AND post_date \u003e= DATE_SUB(NOW(), INTERVAL 3 MONTH) AND post_modified_gmt \u003e= %s LIMIT 1000\", $date );\n\n    return $query;\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAutomattic%2Fmsm-sitemap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAutomattic%2Fmsm-sitemap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAutomattic%2Fmsm-sitemap/lists"}