Skip to content

Commit d7c2dce

Browse files
fix(limit): introduce numberposts filter
1 parent 9b3d103 commit d7c2dce

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

msm-sitemap.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public static function get_partition_suffix(): string {
6161
return ( empty( $partition ) ? '' : "-$partition" );
6262
}
6363

64+
public static function max_sitemap_length(): int {
65+
return apply_filters( 'msm_sitemap_max_sitemap_length', get_option( 'msm_sitemap_max_sitemap_length', 365 * 3) );
66+
}
67+
6468
/**
6569
* Register 15 minute cron interval for latest articles
6670
* @param array[] $schedules
@@ -722,7 +726,7 @@ public static function build_root_sitemap_xml( $year = false ) {
722726
'post_type' => Metro_Sitemap::SITEMAP_CPT,
723727
'orderby' => 'post_date',
724728
'order' => 'DESC',
725-
'numberposts' => -1,
729+
'numberposts' => self::max_sitemap_length(),
726730
];
727731
if ( is_numeric( $year ) ) {
728732
$args['m'] = $year;

0 commit comments

Comments
 (0)