First check your website for the sitemap output
yourWebsite/wp-sitemap.xml
Now, if the users or author sitemap link shows here, simply follow these steps to remove it.
- Login to cpanel
- Open File Manager
- Select your website folder
- Open wp-includes folder
- Open sitemaps folder
- Open providers folder
- Open the file class-sitemaps-users.php on edit mode
Main Solution
- Find this block of codes
foreach ( $users as $user ) {
$sitemap_entry = array(
'loc' => get_author_posts_url( $user->ID ),
);
/**
* Filters the sitemap entry for an individual user.
*
* @since 5.5.0
*
* @param array $sitemap_entry Sitemap entry for the user.
* @param WP_User $user User object.
*/
$sitemap_entry = apply_filters( 'wp_sitemaps_users_entry', $sitemap_entry, $user );
$url_list[] = $sitemap_entry;
}
return $url_list;
}
- Change the value of $url_list[] to zero. Example:
/**
* to change this line
* $url_list[] = $sitemap_entry;
* and this will be as shown below
*/
$url_list[] = 0;
This will generate sitemaps for users but no users will be in the list as the value set to zero.
- Now if you also want to prevent the users or author sitemap in the first list, find this block of code
public function get_max_num_pages( $object_subtype = '' ) {
/**
* Filters the max number of pages before it is generated.
*
* Passing a non-null value will effectively short-circuit the generation,
* returning that value instead.
*
* @since 5.5.0
*
* @param int $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 ) );
}
- Change the value of
$total_users
to zero. Example :
/**
* to change this line
* $total_users = $query->get_total();
* and this will be as shown below
*/
$total_users = 0;
That's all. Now wp-sitemap will not generate any users
or author
sitemap
If you find this information helpful, please feel free to share it