WP_Sitemaps_Posts::get_object_subtypes() WordPress Method

The WP_Sitemaps_Posts::get_object_subtypes() method is used to get the registered post types for the sitemap.

WP_Sitemaps_Posts::get_object_subtypes() #

Returns the public post types, which excludes nav_items and similar types.


Description

Attachments are also excluded. This includes custom post types with public = true.


Top ↑

Return

(WP_Post_Type[]) Array of registered post type objects keyed by their name.


Top ↑

Source

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

	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 );
	}


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.