wppaste
WordPress

WP_Sitemaps_Posts

Since
5.5.0
Source
wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php:17
Posts XML sitemap provider.

Compatibility

WordPress
since 5.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 6

Every hook that fires from inside WP_Sitemaps_Posts, in the order it appears in the class, grouped by the method that fires it.

Methods · 5

Source code

class WP_Sitemaps_Posts extends WP_Sitemaps_Provider {	/**	 * WP_Sitemaps_Posts constructor.	 *	 * @since 5.5.0	 */	public function __construct() {		$this->name        = 'posts';		$this->object_type = 'post';	} 	/**	 * Returns the public post types, which excludes nav_items and similar types.	 * Attachments are also excluded. This includes custom post types with public = true.	 *	 * @since 5.5.0	 *	 * @return WP_Post_Type[] Array of registered post type objects keyed by their name.	 */	public function get_object_subtypes() {		$post_types = get_post_types( array( 'public' => true ), 'objects' );		unset( $post_types['attachment'] ); 		$post_types = array_filter( $post_types, 'is_post_type_viewable' ); 		/**		 * Filters the list of post object sub types available within the sitemap.		 *		 * @since 5.5.0		 *		 * @param WP_Post_Type[] $post_types Array of registered post type objects keyed by their name.		 */		return apply_filters( 'wp_sitemaps_post_types', $post_types );	} 	/**	 * Gets a URL list for a post type sitemap.	 *	 * @since 5.5.0	 * @since 5.9.0 Renamed `$post_type` to `$object_subtype` to match parent class	 *              for PHP 8 named parameter support.	 *	 * @param int    $page_num       Page of results.	 * @param string $object_subtype Optional. Post type name. Default empty.	 *	 * @return array[] Array of URL information for a sitemap.	 */	public function get_url_list( $page_num, $object_subtype = '' ) {		// Restores the more descriptive, specific name for use within this method.		$post_type = $object_subtype; 		// Bail early if the queried post type is not supported.		$supported_types = $this->get_object_subtypes(); 		if ( ! isset( $supported_types[ $post_type ] ) ) {			return array();		} 		/**		 * Filters the posts URL list before it is generated.		 *		 * Returning a non-null value will effectively short-circuit the generation,		 * returning that value instead.		 *		 * @since 5.5.0		 *		 * @param array[]|null $url_list  The URL list. Default null.		 * @param string       $post_type Post type name.		 * @param int          $page_num  Page of results.		 */		$url_list = apply_filters(			'wp_sitemaps_posts_pre_url_list',			null,			$post_type,			$page_num		); 		if ( null !== $url_list ) {			return $url_list;		}

Changelog

Introduced in 5.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.