Attachment Pages Redirect

설명

There are three possible scenarios where this plugin does something. In all cases, the attachment page must exists, the plugin will not run for deleted attachments:

A) A visitor lands on an attachment page and the parent post is available (not in trash or deleted). A 301 redirect will be issued to redirect the visitor to the parent post.

B) A visitor lands on an attachment page and the parent post was already deleted from trash. A 302 redirect is issued to home page (this can be changed to 301 if you want, see FAQ for more details).

C) A visitor lands on an attachment page and the parent post is in trash, therefore not available for the visitor. It returns a 404 error code to prevent endless redirection loop in old WP releases and redirecting to trashed/not available posts.

There is no options page, simply activate it and will do the job.

If you’re happy with the plugin please don’t forget to give it a good rating, it will motivate me to keep sharing and improving this plugin (and others).

Requirements

  • WordPress 4.8 or higher.

설치

  • Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation (or install it directly from your dashboard) and then activate the Plugin from Plugins page.

FAQ

WordPress is returning a 404 error for my attachment pages, will this plugin help?

No. This plugin needs an existing attachment to work, if you deleted the attachment WordPress will return a 404 for its attachment page and this plugin doesn’t support that scenario.

Can I change the HTTP codes used for the redirections?

Since version 1.1 you can do this by adding constants to your wp-config.php file. The example below will switch the redirection codes used by default.

define( 'ATTACHMENT_REDIRECT_CODE', '302' );
define( 'ORPHAN_ATTACHMENT_REDIRECT_CODE', '301' );

Use this at your own risk, only if you know what you’re doing!! No support will be offered for this.

후기

2023년 4월 22일
Exactly what I needed. Thanks!
2023년 1월 11일
I didn't want any attachment pages to be accessed by visitors, then found this plugin that does the job by just installing and activating. Thanks!
2021년 9월 20일
Works perfectly with no config needed. Doesn't get better than this folks.
2021년 7월 24일
The problem was driving me crazy. Thankyou!
모든 46 평가 읽기

기여자 & 개발자

“Attachment Pages Redirect”(은)는 오픈 소스 소프트웨어입니다. 다음의 사람들이 이 플러그인에 기여하였습니다.

기여자

“Attachment Pages Redirect”(이)가 2(으)로 번역되었습니다. 기여해 주셔서 번역자님께 감사드립니다.

자국어로 “Attachment Pages Redirect”(을)를 번역하세요.

개발에 관심이 있으십니까?

코드 탐색하기는, SVN 저장소를 확인하시거나, 개발 기록RSS로 구독하세요.

변경이력

1.1.2

  • Changed code for 404 scenario to use the theme’s 404 template if it’s available.

1.1.1

  • Minor changes to make code 100% compliant with WordPress Coding Standards. This doesn’t means any change in the plugin functionality, it’s just code cosmetic.

1.1

  • Minor coding standards improvements.
  • Added ATTACHMENT_REDIRECT_CODE and ORPHAN_ATTACHMENT_REDIRECT_CODE constants to allow change the HTTP redirection codes (e.g. change 302 to 301 for orphan attachments)
  • Prevent endless redirection loop in old WP releases and redirecting to trashed/not available posts if an attachment page is visited when parent post is in trash. Returning a 404 error in this case.

1.0

  • Initial release.