Upload images to custom folder in wordpress

upload images to custom folder in wordpress

* in your functions.php file put the below code:
*** here you can change the uploads_img folder name to anything

function ashique_custom_image_dir( $pathdata ) {
$subdir = ‘/uploads_img’.$pathdata[‘subdir’];
$pathdata[‘path’] = str_replace($pathdata[‘subdir’], $subdir, $pathdata[‘path’]);
$pathdata[‘url’] = str_replace($pathdata[‘subdir’], $subdir, $pathdata[‘url’]);
$pathdata[‘subdir’] = str_replace($pathdata[‘subdir’], $subdir, $pathdata[‘subdir’]);
return $pathdata;
}

add_filter( ‘upload_dir’, ‘ashique_custom_image_dir’ );

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>