Save Images to directory Postname
-
How do I save images to custom directory based on postname or posttitle. I have scraped a list of product names and image urls, i want to save all images to /uploads/{postname}/{image_1.jpg} eg: /uploads/MSIRX580/image_1.jpg
The default method of saving 30k images on a single directory is not ideal or organised for me.
I tried this code but WP All Import doesn’t create or save in any directory.
function add_date_to_upload_dir( $param ) { $the_post = $_REQUEST['post_id']; $dir = '/' . $the_post->post_name . '/' ; $param['path'] = $param['path'] . $dir; $param['url'] = $param['url'] . $dir; return $param; } add_filter( 'upload_dir', 'add_date_to_upload_dir' );
[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Save Images to directory Postname’ is closed to new replies.