and like us on FB

If you upload an image via the WordPress image library, of you have it imported in your code to a post or page, that image will be available as a standalone page that displays the image in full. While these pages might have their place in the world of photography when a theme properly supports attachments (and most don’t), the page is little redundant… and isn’t necessarily advantageous for your SEO. In my opinion, the attachment pages detracts from the average user experience because the image is set on a page without the relevant context.

In my case, I recently build a little site that had some wallpaper images that were automatically uploaded to the media gallery (thus creating their own image page) but I wanted to track each full scale image download (via a URL rewrite) to get an idea of what was popular. Each image having its own page negated this feature.

The solution was to provide a small function that would redirect image/attachment pages to their parent page or, if the image didn’t have a post parent, to the website home page. It’s a simple DIY SEO technique that can be easily accomplished in under 1 minute. Adding this very basic feature to a website is part of the much broader SEO packages that we make available to clients.

Shortcode Function

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

The same style of redirect can be applied so any post type can be redirected to any other.

Download

Title: Redirect WP Image Attachment Page to Parent Post
Description: Redirects image attachment pages to their parent post or page.
Download: Shortcode (V0.2) | WP Plugin (V0.2) | | Plugin Page

Shortt URL for this post: http://shor.tt/113S