WordPress.org

Ready to get started?Download WordPress

Forums

How to 404 Redirect Deleted Tag Pages? (18 posts)

  1. davidjoseph
    Member
    Posted 1 year ago #

    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!

  2. Santosh
    Member
    Posted 1 year ago #

    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.

  3. riversatile
    Member
    Posted 1 year ago #

    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 ?

  4. riversatile
    Member
    Posted 1 year ago #

    @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.

  5. Santosh
    Member
    Posted 1 year ago #

    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

  6. riversatile
    Member
    Posted 1 year ago #

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

  7. davidjoseph
    Member
    Posted 1 year ago #

    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.

  8. riversatile
    Member
    Posted 1 year ago #

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

  9. davidjoseph
    Member
    Posted 1 year ago #

    There is a category.php but no tag.php

  10. esmi
    Forum Moderator
    Posted 1 year ago #

    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.

  11. davidjoseph
    Member
    Posted 1 year ago #

    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.]

  12. esmi
    Forum Moderator
    Posted 1 year ago #

    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

  13. davidjoseph
    Member
    Posted 1 year ago #

    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; ?>
  14. esmi
    Forum Moderator
    Posted 1 year ago #

    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.

  15. davidjoseph
    Member
    Posted 1 year ago #

    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; ?>
  16. esmi
    Forum Moderator
    Posted 1 year ago #

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

  17. davidjoseph
    Member
    Posted 1 year ago #

    Thanks for the link, I have read over it, but I am still not sure how to make the code call the 404.php file and "throw" the 404 error. That link mainly speaks about how to create a 404 error page (which I already have - 404.php), but it does not say how to "call" it. In fact, it specifically says not to "hard code the path" to the 404 file. If I take out the code I pasted above that currently displays "No Archive Found", the 404.php is not getting called by default. So any thoughts on what to do to get the 404.php to get called in this scenario?

  18. davidjoseph
    Member
    Posted 1 year ago #

    Any more advice or suggestions? I've been working on this all day to no avail. I really need to figure out how to get my theme to return proper 404 errors instead of just displaying the "No Archive Found" message...

Topic Closed

This topic has been closed to new replies.

About this Topic