Modify upload directory to use post category slug in file path on multisite installation
try this: function add_taxonomy_to_upload_dir( $upload ) { if ( isset( $_REQUEST[‘post’] ) ) { // wp-json/wp/v2/media $post = get_post( $_REQUEST[‘post’] ); } elseif ( isset( $_REQUEST[‘post_id’] ) ) { // wp-admin/async-upload.php $post = get_post( $_REQUEST[‘post_id’] ); } else { return $upload; } if ( ! $post || empty( $post->ID ) ) { return $upload; } … Read more