aioseo_public_post_types

Purpose & version added

This filter can be used to manage the public post types.

Arguments (1)

  1. $postTypes (array) – A list of public post types.
  2. $namesOnly (bool) – Whether only the names should be returned.
  3. $hasArchivesOnly (bool) – Whether or not to only include post types which have archives.

Example code snippet

The code snippet below is just an example of how this filter can be used. In the example below, we’ll remove the movie post type from the public post type list.

// Removes the movie post type from the public post type list.
add_filter( 'aioseo_public_post_types', 'aioseo_filter_public_post_types' );
function aioseo_filter_public_post_types( $postTypes ) {
	$filteredPostTypes = [];
	foreach ( $postTypes as $postTypeObject ) {
		if ( 'movie' === $postTypeObject['name'] ) {
			continue;
		}
		$filteredPostTypes[] = $postTypeObject;
	}

	return $filteredPostTypes;
}

Changelog

VersionDescription
4.1.6Introduced.