🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

How to Set the Image Upload Folder for a Self-Built WordPress Website

After installing WordPress by default, uploaded images are stored on the server in a year/month folder structure. However, if many images are uploaded in a particular month, along with automatically generated thumbnails, the folder can contain tens of thousands of images, affecting server efficiency. Therefore, we need to customize the WordPress upload path.

Method 1: Customizing the WordPress Upload Folder

We can install the Custom Upload Dir plugin to achieve this. This plugin allows you to customize the upload path.You can construct variable paths from elements like the Post title, Category, Post author, and Publication date.etc. WordPress自定义上传路径 Download Link

Method 2: Customizing the WordPress Upload Folder

This is a plugin-free method using code. Insert the following code into your website Theme's functions.php file to upload to a specified folder.
add_filter('upload_dir', 'awesome_wallpaper_dir');

function awesome_wallpaper_dir( $param ){
    $mydir = '/awesome';

    $param['path'] = $param['path'] . $mydir;
    $param['url'] = $param['url'] . $mydir;

    return $param;
}
/awesome is the path you set. For details, please refer to: https://codex.wordpress.org/Plugin_API/Filter_Reference/upload_dir

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step.

「Naibabiji WordPress Website Building Coaching Service」—From choosing a domain and buying hosting, to installing a Theme and publishing content, I「ll coach you through every step, helping you avoid detours and reach your goal directly.

👉 Learn about the Website Building Coaching Service
🔒

Comments are closed

The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.

×
二维码

Scan QR Code to Follow

AI Website Building Assistant

🤖
Hello! I am the Naibabiji AI Assistant. How can I help you?
Quick Consultation: