Noindex 404 pages from functions.php in child theme (1 post)

  1. Ate Up With Motor
    Posted 2 years ago #

    I'm setting up a custom 404 page for my website that will be more helpful to visitors who have gotten a bad link. While I'm doing that, I would like to make sure that the 404 page's meta robots tag is set to noindex, follow. (I know that search engine robots will usually not index 404 pages, but I'd like to be certain.)

    All the suggestions I'm finding for doing that involve adding an if statement to the theme's header.php file, which is definitely not ideal. (I'm using a child theme and while I could duplicate and modify the parent theme's header.php, I would rather not do that -- there's a lot of other stuff in that file and I want to make sure it updates when the theme updates!)

    Is there a function I can add to the child's functions.php to change the meta robots tags only for 404s? I'm guessing it would involve modifying the wp_head() function, but I'm afraid I have no idea how.


Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by Ate Up With Motor
  • This topic is not resolved
  • WordPress version: 3.6.1