WP_Sitemaps_Users::get_max_num_pages() WordPress Method

The WP_Sitemaps_Users::get_max_num_pages() method is used to get the maximum number of pages for a user sitemap. This is useful for determining the number of sitemap pages to generate for a user sitemap.

WP_Sitemaps_Users::get_max_num_pages( string $object_subtype = '' ) #

Gets the max number of pages available for the object type.


Description

Top ↑

See also


Top ↑

Parameters

$object_subtype

(string)(Optional) Not applicable for Users but required for compatibility with the parent provider class.

Default value: ''


Top ↑

Return

(int) Total page count.


Top ↑

Source

File: wp-includes/sitemaps/providers/class-wp-sitemaps-users.php

	public function get_max_num_pages( $object_subtype = '' ) {
		/**
		 * Filters the max number of pages for a user sitemap before it is generated.
		 *
		 * Returning a non-null value will effectively short-circuit the generation,
		 * returning that value instead.
		 *
		 * @since 5.5.0
		 *
		 * @param int|null $max_num_pages The maximum number of pages. Default null.
		 */
		$max_num_pages = apply_filters( 'wp_sitemaps_users_pre_max_num_pages', null );

		if ( null !== $max_num_pages ) {
			return $max_num_pages;
		}

		$args  = $this->get_users_query_args();
		$query = new WP_User_Query( $args );

		$total_users = $query->get_total();

		return (int) ceil( $total_users / wp_sitemaps_get_max_urls( $this->object_type ) );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.