Snippet Category SEO Improvements

Redirect Attachment Pages to Parent Post

add_action('template_redirect', 'attachment_redirect');
function attachment_redirect() {
    global $post;
    if (is_attachment() && isset($post->post_parent) && is_numeric($post->post_parent) && ($post->post_parent != 0)) {
        wp_redirect(get_permalink($post->post_parent), 301);
        exit;
    }
}

Remove Category Base

add_action('init', 'remove_category_base');
function remove_category_base() {
    global $wp_rewrite;
    $wp_rewrite->category_base = '';
    $wp_rewrite->flush_rules();
}