Is there a user-facing interface to edit an attachment’s permalink?

This’ll add a slug field to the edit attachment page, which’ll allow you to independently change it when and how you choose to.

Drop it into a plugin or your theme’s functions.php;

function wpse_12405_edit_attachment_name( $fields, $post ) {
    $fields['post_name'] = array(
        'label' => __( 'Slug' ),
        'value' => $post->post_name,
    );

    return $fields;
}

add_filter( 'attachment_fields_to_edit', 'wpse_12405_edit_attachment_name', 10, 2 );

function wpse_12405_save_attachment_name( $attachment, $POST_data ) {
    if ( ! empty( $POST_data['post_name'] ) )
        $attachment['post_name'] = $POST_data['post_name'];

    return $attachment;
}

add_filter( 'attachment_fields_to_save', 'wpse_12405_save_attachment_name', 10, 2);

Leave a Comment