SEO & Analytics Guide Beginner 3 min

Stop WordPress Creating Pages Google Doesn’t Need

Attachment pages, date archives, author pages on one-person sites and tags with one post. WordPress creates them all, and search engines crawl them. How to redirect, noindex or drop them from your sitemap.

TutorialBeginner12 minTested on WordPress 7.1Updated November 13, 2026

Search engines judge a site partly by the pages it offers them. If half the URLs on your site are near-empty pages WordPress made automatically, crawlers spend their time on those instead of your posts, and your real pages can end up competing with copies of themselves. None of these pages hurt on their own. Together, on a site with a few years of uploads and tags, they can outnumber your content.

Already using an SEO plugin?

Slim SEO, Yoast, Rank Math and others have settings for most of the pages below. Use those settings rather than adding code, so you don’t end up with two conflicting rules. The snippets here are for sites without one, or for cases the plugin doesn’t cover.

Attachment pages: redirect them

Every file you upload gets its own page showing just that image or PDF. Visitors almost never need it, and it can rank instead of the post the image belongs to.

Since WordPress 6.4, new sites have attachment pages turned off. Sites created before that still have them. This redirects each one to the post the file was uploaded to, or to the homepage if it wasn’t attached to anything:

functions.phpPHP
add_action( 'template_redirect', function() {
    if ( ! is_attachment() ) return;

    $parent_id = get_post()->post_parent;

    if ( $parent_id ) {
        wp_redirect( get_permalink( $parent_id ), 301 );
    } else {
        wp_redirect( home_url( '/' ), 301 );
    }

    exit;
} );
Tested on WordPress 7.1 · PHP 8.3Checked November 13, 2026

The redirect is a permanent 301, so search engines move any signals the old pages had to the post and drop the attachment URLs over the following weeks.

Thin archives: noindex them

Date archives, author archives on a site with one author, and tag pages with one or two posts mostly repeat what’s already on your blog page. They’re fine for visitors, so don’t delete them. Tell search engines not to index them, while still following their links to your posts:

functions.phpPHP
add_filter( 'wp_robots', function ( array $robots ): array {
	$noindex = false;

	// Date archives (/2026/11/) usually duplicate your normal archives.
	if ( is_date() ) {
		$noindex = true;
	}

	// Author archives duplicate the blog on sites with only one author.
	if ( is_author() && count( get_users( [ 'capability' => 'edit_posts', 'has_published_posts' => true, 'fields' => 'ID', 'number' => 2 ] ) ) < 2 ) {
		$noindex = true;
	}

	// Tag pages with fewer than 3 posts are thin.
	if ( is_tag() && get_queried_object()->count < 3 ) {
		$noindex = true;
	}

	if ( $noindex ) {
		$robots['noindex'] = true;
		$robots['follow']  = true;
	}
	return $robots;
} );
Tested on WordPress 7.1 · PHP 8.3Checked November 13, 2026

It uses WordPress’s own robots API, so there’s one robots tag on the page, not two.

Don't noindex page 2, 3, 4…

Paginated archives like /blog/page/2/ are how crawlers reach your older posts. Google no longer recommends noindexing them. The snippet leaves them alone on purpose.

Single pages that shouldn’t be found

Some pages exist only for people who’ve just done something: a thank-you page after a form, a download page, a members area. Searchers landing on them directly is confusing at best:

Snippet

Noindex Specific Pages

Add noindex to pages that shouldn't appear in search results, such as thank-you pages and members-only areas.

PHPBeginner
View

Keep your sitemap clean

Your sitemap is the list of pages you’re asking search engines to index. It should match the decisions above. WordPress’s built-in sitemap at /wp-sitemap.xml lists users, and with them their usernames, by default:

Snippet

Remove Users From the WordPress Sitemap

Stop WordPress listing author archive URLs, and with them your usernames, in its built-in XML sitemap.

PHPBeginner
View

Leave out whole content types you’ve noindexed, such as tags:

Snippet

Remove Post Types and Taxonomies From the Sitemap

Keep content types you don't want indexed, such as tags or a private custom post type, out of WordPress's XML sitemap.

PHPBeginner
View

And add last-modified dates, so search engines can tell which pages changed and recrawl those first:

Snippet

Add Last-Modified Dates to the Sitemap

Add a lastmod date to every post and page in WordPress's sitemap, so search engines know what changed.

PHPBeginner
View
You should now see

An old attachment URL redirects to its post. A date archive’s source contains one robots tag with noindex, follow. Your sitemap no longer lists users or tags, and its entries show a lastmod date.

Then wait, and check

None of this changes search results overnight. Over the next few weeks, Google Search Console’s Pages report should show the redirected and noindexed URLs moving out of the index, and the number of indexed pages getting closer to the number of pages you actually wrote.

Summary

Redirect attachment pages, noindex date archives, single-author pages and near-empty tags, and noindex pages only meant for people who’ve just taken an action. Then make your sitemap match. If you use an SEO plugin, make these changes in its settings instead.

Check your understanding

1Why noindex a date archive instead of redirecting it?
2Should you noindex /blog/page/2/?

Was this helpful?

Written by Nahnu Plugins

We build and maintain WordPress plugins. Every guide is tested on a fresh WordPress site before it goes out, and checked again when WordPress updates.

More guides

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only