I am trying to import items based on the week now I dont want to manually change this every week but want to have this automated. So I made this code
function my_is_post_to_update( $continue, $post_id, $xml_node, $import_id ) {
// Run this code only for a specific import (import ID 5)
if ($import_id == '20') {
// Get the current week number
$current_week = 7;
// Get the week from the XML node
$week = $xml_node['week'];
// Debugging logs
error_log("Import ID: $import_id - Current Week: $current_week, XML Week: $week");
// If week is valid and matches the current week, continue the import
if ($week == $current_week) {
error_log("Importing record for week $week (matches current week).");
return true; // Continue importing
} else {
error_log("Skipping record: Week in XML ($week) does not match current week ($current_week).");
}
}
// Skip this post if the week doesn't match the current week
return false;
}
add_filter( 'wp_all_import_is_post_to_update', 'my_is_post_to_update', 10, 4 );
So its skipping all rows. I use it on existing items and my import id = 20. So I think I am doing something wrong with the week.
