Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fcsp_type_upload_dir( $args ) {
- // Get the current post_id
- $id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : '' );
- if( $id ) {
- // Set the new path depends on current post_type
- $newdir = '/' . get_post_type( $id );
- $args['path'] = str_replace( $args['subdir'], '', $args['path'] ); //remove default subdir
- $args['url'] = str_replace( $args['subdir'], '', $args['url'] );
- $args['subdir'] = $newdir;
- $args['path'] .= $newdir;
- $args['url'] .= $newdir;
- }
- return $args;
- }
- add_filter( 'upload_dir', 'fcsp_type_upload_dir' );
- define( 'UPLOADS', trailingslashit( WP_CONTENT_DIR ) . '$newdir' );
Add Comment
Please, Sign In to add comment