A fresh mix of code snippets and tutorials

WordPress Disable Author Archives

This WordPress snippet disables all author-archive views. This may be useful to prevent user enumeration scans, and also may help to minimize duplicate content (for SEO purposes).

To disable all author archives, add the following code snippet to your theme’s functions.php file:

// disable author archives
function shapeSpace_disable_author_archives() {
	if (is_author()) {
		global $wp_query;
	} else {
remove_filter('template_redirect', 'redirect_canonical');
add_action('template_redirect', 'shapeSpace_disable_author_archives');

Once in place, this code checks if the request is for an author archive, and if so, redirects as a 404 (Not Found) request. No editing is required, but you may want to tweak the redirect/response to something more user-friendly. For more information, check out my tutorial on stopping user-enumeration scans in WordPress.

Learn more

Digging Into WordPressWordPress Themes In DepthWizard’s SQL Recipes for WordPress