How to Hide Everything in the Footer from Indexing in WordPress

How to Hide Everything in the Footer from Indexing in WordPress

In today’s article, we’ll look at how to prevent the website footer from being indexed by search engine bots. Why might this be necessary? There are many possible reasons, including:

  • Hiding advertising links;
  • Hiding links to restricted sections of the website;
  • Content that should not be indexed;
  • etc.

In this example, we’ll modify the default WordPress theme “Twenty Twelve.” If you don’t have it — install it. The first thing we need to do is create a child theme (you can learn how to do that in this article).

Why use a child theme instead of editing the main/downloaded theme directly? Because of updates — if you intentionally or accidentally update the theme you modified, all your changes will be overwritten. You’ll have to reapply them from scratch.

So, have you downloaded the theme? Great. Now activate it under “Appearance” – “Themes.” Go to the frontend and open the browser inspector (in Google Chrome, right-click on the site page and select “Inspect” or press Ctrl + Shift + I). Then click the element picker icon (the first icon on the top-left of the panel where “Elements” tab is), and hover over the page until you find the footer. Click on it (see the screenshot below):

How to find the footer via inspector

Once you select the required HTML block on the page, the corresponding tag will be highlighted in the inspector. This helps you locate the footer code. In our example (screenshot), I marked it with a red border on the right. Pay attention to attribute names and their values — you’ll need them to find the matching code in the theme files.

Copy these attributes (either all or just something like “<footer id="colophon" role="contentinfo">”), then open a file browser or code editor and search the theme’s files for this snippet. If you’re lucky, you’ll find the footer. In the “Twenty Twelve” theme, it’s pretty straightforward: the code is located in “wp-content/themes/twentytwelve/footer.php.” But with other themes, it may be more complicated, especially if attributes are generated dynamically (from the database, etc.), so search may not help, and you’ll need to dig into the theme structure.

Next, copy the footer file into your child theme. In my case, the file will be located at:
`wp-content/themes/twentytwelve-child/footer.php`.
Wrap the entire footer in a `` tag and save it:

<noindex>
	<footer id="colophon" role="contentinfo">
		<div class="site-info">
			<?php do_action( 'twentytwelve_credits' ); ?>
			<?php
			if ( function_exists( 'the_privacy_policy_link' ) ) {
				the_privacy_policy_link( '', '<span role="separator" aria-hidden="true"></span>' );
			}
			?>
			<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentytwelve' ) ); ?>" class="imprint" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentytwelve' ); ?>">
				<?php
				/* translators: %s: WordPress */
				printf( __( 'Proudly powered by %s', 'twentytwelve' ), 'WordPress' );
				?>
			</a>
		</div><!-- .site-info -->
	</footer><!-- #colophon -->
</noindex>

Now go back to the frontend, refresh the page, open the inspector, locate the footer — and you’ll see that it’s now wrapped in a `` tag.

This means search engines will no longer be able to index the content inside your website’s footer.

Are you having problems with your WordPress site? Do you need additional functionality? A custom plugin or a new page?
Then write to me via the feedback form, and I will try to help you.

Write a comment

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