You might be getting WordPress’s default category of Uncategorized showing up in your sitelinks on Google searches, something like this:

WordPress default category appearing in Google sitelinks

It’s messy, it’s ugly, it looks unprofessional. But what can you do about it? Google builds these sitelinks automatically based on what it finds and deems to be interesting on your site. Sometimes Google gets it wrong and sitelinks something completely uninteresting!

Noindex Tags

A solution to this is to add a noindex meta tag to the page that is showing up in sitelinks. Noindex tags let search engines know that they shouldn’t index a page because the site owner doesn’t want it to show up in searches. This is what it looks like, and it lives in the header of the page that shouldn’t be indexed:

<meta name="robots" content="noindex">

If you wanted to prevent only Google as opposed to all the bots from indexing it, you could use the specific Googlebot tag:

<meta name="googlebot" content="noindex">

But it’s not so easy to put tags in the header of a WordPress category. You can set categories to be noindex with a plugin such as Yoast, but maybe you think installing a whole plugin just to remove an annoying link showing up is overkill.

Luckily you don’t have to. You can also do it with the wp_robots hook. (please note this might not work if you already have a plugin installed that messes with robots meta tags as they’ll already being putting these tags in themselves. It’s worth checking what’s in the header of the page you’re trying to alter)

So to no index a category page:

add_filter( 'wp_robots', function( $robots ) {

  if (is_category('uncategorized')) {
    $robots['noindex'] = true;

  return $robots;

You could equally ask Google not to index author pages (or pretty much any page you want):

add_filter( 'wp_robots', function( $robots ) {

  if (is_author()) {
    $robots['noindex'] = true;
  return $robots;

To check that these are working, open developer tools on your browser – in Chrome and Firefox you can do this by right clicking on the page and selecting ‘inspect’. Then search (cmd/ctrl F) for ‘robots’ and check that that tag now has noindex in it.

Removing Uncategorized from Sitemap

Now that you’ve added noindex tags to the pages you don’t want indexed, you might also want to remove those pages from your sitemap. These days WordPress will automatically create a sitemap for you, but it’s not so easy to alter it.

There is a wealth of information here at Perishable Press on customising sitemaps with code if you want to read up on it, but it doesn’t go as far as to tell you how to remove a category.

I finally found the answer to this puzzle buried in this git repo. It contains this snippet which works perfectly on my site:

  function( $args ) {
    $args['exclude'] = isset( $args['exclude'] ) ? $args['exclude'] : array();
    $args['exclude'][] = 1;
    return $args;

This snippet is using the wp_sitemaps_taxonomies_query_args filter. Uncategorized is category number 1 in WP. So I’ve put a 1 in the ‘$args[‘exclude’][] = 1;’ line to exclude that category from my sitemaps. 

If this doesn’t work straight away, go back to your permalinks page and hit save a few times, which flushes the permalinks and should regenerate the sitemap.

Hey there – thanks for reading!
Have I helped you? If so, could you…
Remove Uncategorized from Google sitelinks without a plugin – WordPress
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *