How to Install WordPress Plugins and T...
Facing issues installing WordPress plugins or themes without FTP? This snippet provid...

WPCodeBox
715
Optimize your WordPress site! Learn how to upload WP All Import images to folders based on the post date (Y/m format) for better organization and SEO. For example, a June 1st, 2017 post’s images go to /wp-content/uploads/2017/06.
<?php
if ( ! function_exists( 'wpcb_set_import_img_upload_folder_by_post_date' ) ) {
function wpcb_set_import_img_upload_folder_by_post_date($uploads, $articleData, $current_xml_node, $import_id) {
if ( ! empty($articleData['post_date'])) {
$uploads['path'] = $uploads['basedir'] . '/' . date("Y/m", strtotime($articleData['post_date']));
$uploads['url'] = $uploads['baseurl'] . '/' . date("Y/m", strtotime($articleData['post_date']));
if (!file_exists($uploads['path'])) {
mkdir($uploads['path'], 0755, true);
}
}
return $uploads;
}
}
add_filter('wp_all_import_images_uploads_dir', 'wpcb_set_import_img_upload_folder_by_post_date', 99, 4);





