要解决问题1,可以挂接以添加\\u附件并编辑\\u附件挂接。
add_action(\'add_attachment\', \'wpse_set_attachment_category\');
add_action(\'edit_attachment\', \'wpse_set_attachment_category\');
function wpse_set_attachment_category( $post_ID )
{
// if attachment already have categories, stop here
if( wp_get_object_terms( $post_ID, \'category\' ) )
return;
// no, then get the default one
$post_category = array( get_option(\'default_category\') );
// then set category if default category is set on writting page
if( $post_category )
wp_set_post_categories( $post_ID, $post_category );
}