How to Disable Attachment Post in WordPress?

No doubt that Wordpres is the most popular blogging platform. It’s easy to use and most importantly, highly search engine optimized. To get the maximum advantage in search engines you have to select minimum number of very important pages to be indexed.

You must have already marked sub-archive pages and date based archives as ‘noindex’ may be author, tag and category archives as well. But that’s not all about it.

Once you attach image to a post it’s creating a separate attachment post page for each image. These posts don’t give you any advantage in SEO and they are not useful for your readers as well.

Unfortunately there is no way for you to disable them with default WordPress options and here is how to do it.

How-to-Disable-Attachment-Post-in-Wordpress

With WordPressSEO Plug-in

If you are already using WordPressSEO plug-in, there you have the option to permanently redirect all the attachment post to related parent post. Go to wordpress backend -> SEO -> permalinks and check “Redirect attachment URL’s to parent post URL”.

Problem solved! Now if someone tries to access attachment post link it will be automatically directed to parent post.

Without any Plug-In

If you are not using WordPressSEO plug-in still you can get the same thing done with minor code alteration.

Go to your hosting account and access the file manager. Then go to WordPress theme folder, create a file named “attachment.php” and put the below code there.

<?php header ('HTTP/1.1 301 Moved Permanently'); header ('Location: '.get_permalink($post->post_parent)); ?>

This will drastically reduce the number of pages in your blog and get all the attention of Search engines as well as users to main post pages.

Tags: # # #

Get Updates

Spread the Word

What’s Next?

Leave a Reply

Copyright © 2014 Silicon Station. All rights reserved.