Return to Snippet

Revision: 20833
at November 26, 2009 09:37 by ksantoshp


Initial Code
add_filter('upload_dir', 'my_upload_dir');
$upload = wp_upload_dir();
remove_filter('upload_dir', 'my_upload_dir');
function my_upload_dir($upload) {
        $upload['subdir'] = '/sub-dir-to-use' . $upload['subdir'];
        $upload['path'] = $upload['basedir'] . $upload['subdir'];
        $upload['url'] = $upload['baseurl'] . $upload['subdir'];
        return $upload;
}

Initial URL
http://yoast.com/articles/

Initial Description
(Ref: http://yoast.com)

While preparing my previous post on new features in WordPress 2.9, I ran across a ticket in Trac for something I'd been wanting to do for a while: specify a subfolder of the uploads directory for specific plugins, like my Blog Icons plugin, to upload their files to. This way, the blog icons plugin would upload its files to /uploads/blog-icons/, which is a lot better for everyone.

Initial Title
Wordpress upload for plugin

Initial Tags
wordpress

Initial Language
PHP