Media upload directory based on custom post types
-
I’m trying for a long time add a custom post type based directory system in my site, like: uploads/post/image.png.
I have seen many articles and questions on StackExchange, stackoverflow, here on the forum, but nothing worked for me.
My current code creates a folder based on custom post type approach, however uploading the pictures and the url of them is on uploads folder.
function post_type_dir($param){ $screen = get_current_screen(); $mydir = (string)$screen->post_type; echo $mydir. '<br />'; $param['path'] = $param['path'] .'/'. $mydir; $param['url'] = $param['url'] .'/'. $mydir; $param['subdir'] = $mydir; error_log("path={$param['path']}"); error_log("url={$param['url']}"); error_log("subdir={$param['subdir']}"); error_log("basedir={$param['basedir']}"); error_log("baseurl={$param['baseurl']}"); error_log("error={$param['error']}"); return $param; }
I’m going crazy with this, please, someone has been there and managed to solve this problem?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Media upload directory based on custom post types’ is closed to new replies.