For versions later than WordPress 3.5, the setting of the page Upload path (upload_path) and file URL (upload_url_path) for Media in the background is hidden, as shown in the following figure. Some friends need this function, so what should we do? Here we will introduce two methods to retrieve this function.
Code Retrieval
Add the following code to functions. php to restore the function:
// Retrieve Upload settings
If (get_option ('upload _ path') = 'WP-content/uploads' | get_option ('upload _ path') = null ){
Update_option ('upload _ path', WP_CONTENT_DIR. '/uploads ');
}
Options. php
Access http: // site_url/wp-admin/options. php directly, find the following options and set them as the required parameters.
You can also directly use the program. You can add the following code to funtions. php:
Add the following code to the last of the topic's functions. php?> Front:
Add_filter ('upload _ dir', 'wpjam _ custom_upload_dir ');
Function wpjam_custom_upload_dir ($ uploads ){
$ Upload_path = '';
$ Upload_url_path = '';
If (empty ($ upload_path) | 'WP-content/uploads' ===$ upload_path ){
$ Uploads ['basedir'] = WP_CONTENT_DIR. '/uploads ';
} Elseif (0! = Strpos ($ upload_path, ABSPATH )){
$ Uploads ['basedir'] = path_join (ABSPATH, $ upload_path );
} Else {
$ Uploads ['basedir'] = $ upload_path;
}
$ Uploads ['path'] = $ uploads ['basedir']. $ uploads ['subdir'];
If ($ upload_url_path ){
$ Uploads ['baseurl'] = $ upload_url_path;
$ Uploads ['URL'] = $ uploads ['baseurl']. $ uploads ['subdir'];
}
Return $ uploads;
}
Modify $ upload_path and $ upload_url_path in rows 3rd and 4, for example
$ Upload_path = 'IMG ';
$ Upload_url_path = 'http: // www.111cn.net ';