We have a CPT which is used to manage various assets including image, pdf, CAD and other files.
Our client would like to keep these asset files seperate from their other media files and does NOT want them to appear in the WP media panel.
We have found this useful snippet which allows us to upload to a custom folder inside the WP uploads folder:
function my_upload_dir($upload) {
$upload['subdir'] = '/assets';
$upload['path'] = $upload['basedir'] . $upload['subdir'];
$upload['url'] = $upload['baseurl'] . $upload['subdir'];
return $upload;
}
add_filter('upload_dir', 'my_upload_dir');
$uploaded_file = wp_handle_upload($_FILES['xxxx'], $upload_overrides);
remove_filter('upload_dir', 'my_upload_dir');
How could we adapt this properly to upload images for this CPT to a custom 'assets' folder, for example: wp-content/assets ?
Thanks in advance for any help!