{"id":18173,"date":"2012-05-16T16:00:55","date_gmt":"2012-05-16T16:00:55","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/attachment-pages-redirect\/"},"modified":"2026-01-16T11:00:48","modified_gmt":"2026-01-16T11:00:48","slug":"attachment-pages-redirect","status":"publish","type":"plugin","link":"https:\/\/ceb.wordpress.org\/plugins\/attachment-pages-redirect\/","author":2889868,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.1.2","stable_tag":"1.1.2","tested":"6.9.4","requires":"4.8","requires_php":"5.6","requires_plugins":null,"header_name":"Attachment Pages Redirect","header_author":"Samuel Aguilera","header_description":"","assets_banners_color":"","last_updated":"2026-01-16 11:00:48","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"http:\/\/www.samuelaguilera.com","rating":4.9,"author_block_rating":0,"active_installs":20000,"downloads":181941,"num_ratings":47,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0":{"tag":"1.0","author":"samuelaguilera","date":"2017-03-05 12:05:59"},"1.1":{"tag":"1.1","author":"samuelaguilera","date":"2019-06-15 23:37:21"},"1.1.1":{"tag":"1.1.1","author":"samuelaguilera","date":"2020-04-26 10:54:26"},"1.1.2":{"tag":"1.1.2","author":"samuelaguilera","date":"2026-01-16 11:00:48"}},"upgrade_notice":{"1.1":"<ul>\n<li>Recommended upgrade. Read changelog in WordPress.org for more details.<\/li>\n<\/ul>"},"ratings":{"1":1,"2":0,"3":0,"4":1,"5":45},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0","1.1","1.1.1","1.1.2"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[932,735,2264,163,727],"plugin_category":[50],"plugin_contributors":[78220],"plugin_business_model":[],"class_list":["post-18173","plugin","type-plugin","status-publish","hentry","plugin_tags-932","plugin_tags-735","plugin_tags-attachment","plugin_tags-images","plugin_tags-redirect","plugin_category-media","plugin_contributors-samuelaguilera","plugin_committers-samuelaguilera"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/attachment-pages-redirect.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>There are three possible scenarios where this plugin does something. In all cases, the attachment page must exists, <strong>the plugin will not run for deleted attachments<\/strong>:<\/p>\n\n<p>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.<\/p>\n\n<p>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).<\/p>\n\n<p>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.<\/p>\n\n<p><strong>There is no options page<\/strong>, simply activate it and will do the job.<\/p>\n\n<p>If you're happy with the plugin <a href=\"https:\/\/wordpress.org\/support\/plugin\/attachment-pages-redirect\/reviews\/?filter=5\">please don't forget to give it a good rating<\/a>, it will motivate me to keep sharing and improving this plugin (and others).<\/p>\n\n<h4>Requirements<\/h4>\n\n<ul>\n<li>WordPress 4.8 or higher.<\/li>\n<\/ul>\n\n<!--section=installation-->\n<ul>\n<li>Extract the zip file and just drop the contents in the <code>wp-content\/plugins\/<\/code> directory of your WordPress installation (or install it directly from your dashboard) and then activate the Plugin from Plugins page.<\/li>\n<\/ul>\n\n<!--section=faq-->\n<dl>\n<dt id=\"wordpress%20is%20returning%20a%20404%20error%20for%20my%20attachment%20pages%2C%20will%20this%20plugin%20help%3F\"><h3>WordPress is returning a 404 error for my attachment pages, will this plugin help?<\/h3><\/dt>\n<dd><p>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.<\/p><\/dd>\n<dt id=\"can%20i%20change%20the%20http%20codes%20used%20for%20the%20redirections%3F\"><h3>Can I change the HTTP codes used for the redirections?<\/h3><\/dt>\n<dd><p>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.<\/p>\n\n<pre><code>define( 'ATTACHMENT_REDIRECT_CODE', '302' );\ndefine( 'ORPHAN_ATTACHMENT_REDIRECT_CODE', '301' );\n<\/code><\/pre>\n\n<p><strong>Use this at your own risk, only if you know what you're doing!! No support will be offered for this.<\/strong><\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.1.2<\/h4>\n\n<ul>\n<li>Changed code for 404 scenario to use the theme's 404 template if it's available.<\/li>\n<\/ul>\n\n<h4>1.1.1<\/h4>\n\n<ul>\n<li>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.<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>Minor coding standards improvements.<\/li>\n<li>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)<\/li>\n<li>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.<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>Initial release.<\/li>\n<\/ul>","raw_excerpt":"Redirect attachment pages or return a 404 error for them based on the parent post status.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/18173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=18173"}],"author":[{"embeddable":true,"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/samuelaguilera"}],"wp:attachment":[{"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=18173"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=18173"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=18173"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=18173"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=18173"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/ceb.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=18173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}