wp_sitemaps_get_max_urls()
Gets the maximum number of elements for a specific Links Map of the specified provider. By default, 2000.
This function is a wrapper for the int - how many links to display on one page of the sitemap of the specified provider. The purpose of this function is to pass the int through the filter wp_sitemaps_max_urls so that it can be modified. The function should be used when creating your own provider.
Hooks from the function
Returns
Int. Maximum number of URLs (links).
Usage
wp_sitemaps_get_max_urls( $object_type );
- $object_type(string) (required)
The name of the data object that the provider works with. It is unique for each provider. For example, for the default WP provider
taxonomies, the object isterm(taxonomy element). Other options from the core: post, term, user.The function receives $object_type, not the name of the provider; essentially, they are the same since the provider always works with some single data object.
Examples
#1 Example of use
This is a piece of the Site Map Provider example.
$per_page = wp_sitemaps_get_max_urls( $this->object_type ); $offset = ( $arg->paged - 1 ) * $per_page; $LIMIT = sprintf( "LIMIT %d, %d", $offset, $per_page ); $sql = "SELECT $SELECT FROM $wpdb->wp_core_data WHERE $WHERE $LIMIT";
Changelog
| Since 5.5.0 | Introduced. |
wp_sitemaps_get_max_urls() wp sitemaps get max urls code WP 6.8.3
function wp_sitemaps_get_max_urls( $object_type ) {
/**
* Filters the maximum number of URLs displayed on a sitemap.
*
* @since 5.5.0
*
* @param int $max_urls The maximum number of URLs included in a sitemap. Default 2000.
* @param string $object_type Object type for sitemap to be filtered (e.g. 'post', 'term', 'user').
*/
return apply_filters( 'wp_sitemaps_max_urls', 2000, $object_type );
}