Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/azanumer/wp-attachment-redirect/archive/refs/heads/main.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
WordPress creates a public page for every media upload. Those attachment pages are thin, duplicate-prone content that search engines love to index and visitors never want to land on. This plugin redirects them away.
What it does
- Redirects attachment pages to the media file itself (default), the parent post, or a 404 page — your choice in Settings → Attachment Redirect.
- Applies to images only, or to all attachment types (PDFs, videos, audio).
- 301 (permanent) or 302 (temporary) redirect status.
- Falls back gracefully: "parent" mode uses the file URL when an attachment has no parent post.
Filters
war_skip_redirect— returntrueto exempt a specific attachment:add_filter( 'war_skip_redirect', function ( $skip, $attachment_id ) { return 123 === $attachment_id; // Keep this one as a real page. }, 10, 2 );
Installation
- Upload the plugin folder to
wp-content/plugins/. - Activate it from Plugins.
- Choose your target under Settings → Attachment Redirect.
License
MIT — see LICENSE.