# Keep Some User Roles Out of Yoast's Author Sitemap

> Removes users with the roles you choose, such as shop managers or contributors, from the Yoast SEO author sitemap.

- Type: PHP
- Runs: Frontend only
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: yoast, sitemap, authors
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/yoast-sitemap-exclude-author-roles/

## Code

```php
// Roles that should not appear in the author sitemap.
$wpide_sitemap_hidden_roles = array( 'shop_manager', 'contributor' );

add_filter( 'wpseo_sitemap_exclude_author', function ( $users ) use ( $wpide_sitemap_hidden_roles ) {
    return array_values( array_filter( (array) $users, function ( $user ) use ( $wpide_sitemap_hidden_roles ) {
        return ! ( $user instanceof WP_User && array_intersect( (array) $user->roles, $wpide_sitemap_hidden_roles ) );
    } ) );
} );
```

## Notes

Only matters when the author sitemap is enabled in Yoast.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep Some User Roles Out of Yoast's Author Sitemap" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
