Skip to content

Commit 65dee22

Browse files
fix(limit): introduce numberposts filter
1 parent 66740f2 commit 65dee22

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

msm-sitemap.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public static function use_custom_queries(): bool {
5555
return ! apply_filters( 'msm_sitemap_avoid_custom_queries', false );
5656
}
5757

58+
public static function get_partition_suffix(): string {
59+
$partition = apply_filters( 'msm_sitemap_partition', '' );
60+
return ( empty( $partition ) ? '' : "-$partition" );
61+
}
62+
63+
public static function max_sitemap_length(): int {
64+
return apply_filters( 'msm_sitemap_max_sitemap_length', get_option( 'msm_sitemap_max_sitemap_length', 365 * 3) );
65+
}
66+
5867
/**
5968
* Register 15 minute cron interval for latest articles
6069
* @param array[] $schedules
@@ -727,7 +736,7 @@ public static function build_root_sitemap_xml( $year = false ) {
727736
'post_type' => Metro_Sitemap::SITEMAP_CPT,
728737
'orderby' => 'post_date',
729738
'order' => 'DESC',
730-
'numberposts' => -1,
739+
'numberposts' => self::max_sitemap_length(),
731740
];
732741
if ( is_numeric( $year ) ) {
733742
$args['m'] = $year;

0 commit comments

Comments
 (0)