Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

WP All Importing using different file name in directory

My price comparison site imports data from a CSV data feed for several different providers. 

The feeds are re-imported daily to ensure updated prices but at the same time it adds a duplicate media image to the following directory and I'm using the plug in WP All Import Pro to import the feeds.

public_html/wp-content/uploads/2018/(current month)

The above directory also contains all other media which is imported such as company logo etc which we need to keep. 

I need to separate the media being uploaded from my data feeds to a separate directory to allow me to easily delete all data older that 24 hours as I know the next import will have the most up to date media.

This is also to bring my file sizes down because having multiple duplicate files is eating up my web space.

My 2 questions are:

How can I adapt the code below to import my media from the data feeds to another custom folder and separate these out into daily directories eg. 2018/08/27

And then where do I add this code to? Is it in public_html/wp-content/themes/rehub-direct/functions.php which is the theme directory.

function wpai_set_custom_upload_folder($uploads, $articleData, $current_xml_node, $import_id) {

$uploads['path'] = $uploads['basedir'] . '/customfolder';

$uploads['url'] = $uploads['baseurl'] . '/customfolder';    

if (!file_exists($uploads['path'])) {

mkdir($uploads['path'], 0755, true);

}

return $uploads;

}

add_filter('wp_all_import_images_uploads_dir', 'wpai_set_custom_upload_folder', 10, 4);


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by BabadookFeb 1, 2019 10:50 PM 11 371 Feb 1, 2019 10:50 PM
Last Post: Babadook
[PHP] by Dale CarnegieMay 15, 2018 11:53 PM 5 154 May 15, 2018 11:53 PM
Last Post: Squito
[PHP] by milknpepperJan 6, 2018 03:57 PM 9 247 Jan 6, 2018 03:57 PM
Last Post: AppleJuice