Вложения в WordPress #SEO #attachment
<?php
function wpb_imagelink_setup() {
$image_set = get_option( 'image_default_link_type' );
if ($image_set !== 'none') {
update_option('image_default_link_type', 'none');
}
}
add_action('admin_init', 'wpb_imagelink_setup', 10);
// ИЛИ
add_action('template_redirect', 'template_redirect_attachment');
function template_redirect_attachment() {
global $post;
// Перенаправление на основную запись:
if (is_attachment()) {
wp_redirect(get_permalink($post->post_parent));
}
}
/* ИЛИ htaccess
RewriteRule (.+)/attachment /$1 [R=301,L]
RewriteCond %{QUERY_STRING} ^attachment_id= [NC]
RewriteRule (.*) $1? [R=301,L]
*/
?>