Forums

[resolved] How do I add a meta tag to my 404 page? (3 posts)

  1. Nightgunner5
    Member
    Posted 2 years ago #

    <?php get_header(); ?> just doesn't work in this situation. It doesn't let me add a meta noindex, nofollow tag, so I can't block googlebot from filling my 404 log with the /category/ page. I tried using a file_get_contents php function, but that made my php code be not parsed and it messed up the format of the page. Is there any easier way to add a meta tag to my 404.php file? Am I missing something really obvious?

  2. BPartch
    Member
    Posted 2 years ago #

    Hello

    In header.php add:

    <?php if( is_404() ) { ?>
     <meta name="robots" content="noindex,nofollow" />
    <?php } ?>

    Hope it helps. :)

  3. Nightgunner5
    Member
    Posted 2 years ago #

    Amazing, I would have never thought that it would be that easy! Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic