Benutzerdefinierte Wpallimport -Funktion, um Daten von XML abzurufen und überspringen, wenn nicht übereinstimmt [geschloPhp

PHP-Programmierer chatten hier
Anonymous
 Benutzerdefinierte Wpallimport -Funktion, um Daten von XML abzurufen und überspringen, wenn nicht übereinstimmt [geschlo

Post by Anonymous »

Ich versuche, Elemente basierend auf der Woche zu importieren. Jetzt möchte ich diese nicht jede Woche manuell ändern, sondern diese automatisch haben. Also habe ich diesen Code < /p>
gemachtfunction 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 );
< /code>
Es überspringt also alle Zeilen. Ich benutze es für vorhandene Elemente und meine Import -ID = 20. Ich denke, ich mache etwas falsch mit der Woche. //i.static.net/dasmiea4.png "/>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post