Skip to content

Commit

Permalink
fix(limit): introduce numberposts filter
Browse files Browse the repository at this point in the history
  • Loading branch information
claimableperch committed Jun 17, 2024
1 parent 66740f2 commit 65dee22
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion msm-sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ public static function use_custom_queries(): bool {
return ! apply_filters( 'msm_sitemap_avoid_custom_queries', false );
}

public static function get_partition_suffix(): string {
$partition = apply_filters( 'msm_sitemap_partition', '' );
return ( empty( $partition ) ? '' : "-$partition" );
}

public static function max_sitemap_length(): int {
return apply_filters( 'msm_sitemap_max_sitemap_length', get_option( 'msm_sitemap_max_sitemap_length', 365 * 3) );
}

/**
* Register 15 minute cron interval for latest articles
* @param array[] $schedules
Expand Down Expand Up @@ -727,7 +736,7 @@ public static function build_root_sitemap_xml( $year = false ) {
'post_type' => Metro_Sitemap::SITEMAP_CPT,
'orderby' => 'post_date',
'order' => 'DESC',
'numberposts' => -1,
'numberposts' => self::max_sitemap_length(),
];
if ( is_numeric( $year ) ) {
$args['m'] = $year;
Expand Down

0 comments on commit 65dee22

Please sign in to comment.