WordPress.org

Support

Support » How-To and Troubleshooting » How to 404 Redirect Deleted Tag Pages?

How to 404 Redirect Deleted Tag Pages?

  • davidjoseph
    Member

    @davidjoseph

    I recently deleted about 150 tags on my health website, because google does not want us covering “sexual health” topics. In Google Webmaster tools I now have a warning that all of the deleted tag pages are not returning 404 messages, so I checked it out and lo and behold the deleted tag pages are not returning 404 messages. How can I set these deleted tag pages (like websitename.com/tag/gonorrhea/ ) to return 404 error messages?

    Thank you so much for your help!

Viewing 15 replies - 1 through 15 (of 17 total)
  • Santosh
    Member

    @santoshait

    there are two ways one is that leave these warning as it is and after few months google will remove those.
    other is install a plugin for 301 redirect and add all the tags urls and redirect to pages on which you want.

    riversatile
    Member

    @riversatile

    Hi,

    First of all, if you don’t get 404 error, what is the retuned message !

    Are you still view the page content that is normally displayed for these tag page ?

    riversatile
    Member

    @riversatile

    @Santash :

    Davidjoseph doesn’t complain Google is still display these tag pages as indexed content… He complains that his website don’t return the 404 error as it’s usually the case if the tag doesn’t exist anymore.

    So that means there is a deeper problem on his wordpress installation / theme.

    Santosh
    Member

    @santoshait

    sorry for not reading properly I thought this question similar to previous post which complain about GWT.
    ” I now have a warning that all of the deleted tag pages are not returning 404 messages,”
    I am not sure about this what he mean i never seen any message on GWT.
    but my solution will still work for him

    riversatile
    Member

    @riversatile

    Sure, if google don’t give the tag page URLs for tag that don’t exist, 404 error will not occurs for any user.

    davidjoseph
    Member

    @davidjoseph

    It doesn’t give a 404 error for those tags that were removed, instead it shows:

    No Archive Found
    Sorry, but you are looking for an archive that isn’t here.

    I don’t want to redirect the pages anywhere, I just want it to give a 404 error.

    riversatile
    Member

    @riversatile

    Do you have TAG.PHP and CATEGORY.PHP files in your Theme folder ?

    davidjoseph
    Member

    @davidjoseph

    There is a category.php but no tag.php

    esmi
    Forum Moderator

    @esmi

    Do you have TAG.PHP and CATEGORY.PHP files in your Theme folder

    What difference would this make? If these template files aren’t present in the theme, then any call to a tag age would fall back – eventually – to index.php as outlined in the Theme Template Hierarchy.

    davidjoseph
    Member

    @davidjoseph

    I see the following in category.php, which is perhaps where the 404 error message would go? Is this correct? And do you know what I should modify it to? Thank you so much for your help!!!

    <?php else : ?>
    	<div class="postgroup">
    		<div class="post listpost">
    			<div class="top"></div>
    			<div class="mid">
    				<div class="title">
    					<h2>No Category Found</h2>
    				</div>
    				<div class="entry errorentry">
    					<p>Sorry, but you are looking for a category that isn't here.</p>
    				</div>
    			</div>
    			<div class="bot"></div>
    		</div>
    	</div>
    <?php endif; ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

    esmi
    Forum Moderator

    @esmi

    No. That template file will NEVER be used for a tag page. If tag.php does not exist, the theme will fall back to archive.php and then index.php.
    http://codex.wordpress.org/Tag_Templates

    davidjoseph
    Member

    @davidjoseph

    I found the code in archive.php that I think we are looking for (see below), but any idea how to change it to make it throw a 404 redirect?

    <?php else : ?>
    
    	<div class="postgroup">
    		<div class="post listpost">
    			<div class="top"></div>
    			<div class="mid">
    				<div class="title">
    					<h2>No Archive Found</h2>
    				</div>
    				<div class="entry errorentry">
    					<p>Sorry, but you are looking for an archive that isn't here.</p>
    				</div>
    			</div>
    		<div class="bot"></div>
    		</div>
    	</div>
    
    <?php endif; ?>
    esmi
    Forum Moderator

    @esmi

    You would need to remove that entire block from this template and all similar blocks in other templates and then create a creating a 404 error page in your theme.

    davidjoseph
    Member

    @davidjoseph

    I have a 404.php custom file in my theme, but how do I call it inside of that? Would it be like this?

    <?php else : ?>
    header('HTTP/1.0 404 Not Found');
    include '404.php';
    <?php endif; ?>
    esmi
    Forum Moderator

    @esmi

    Please see the page I linked to above. It explains the process in great detail.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘How to 404 Redirect Deleted Tag Pages?’ is closed to new replies.