• I have been trying to troubleshoot a plugin that fetches data from an API and stores the data in a mysql database. The problem is that the plugin stopped storing the data a while ago. I deleted some data to free up some space, checked any and all error messages, without luck. The code that stores content in the data base is:

            $new_part_in_wpdb = array(
                'post_title'     => $truck_part_title_without_sku,  // The cleaned title
                'post_content'   => $parts_result['description'],  // The text content
                'post_name'      => $truck_part_slug,  // The name (slug)
                'post_status'    => 'publish',  // Make it live
                'post_type'      => 'part', // Define the CPT
                'post_author'    => 1 // Set an author ID
              );
            $post_id = wp_insert_post( $new_part_in_wpdb );
    
            update_post_meta( $post_id, 'vendor_sku', $parts_result['vendor_sku'] );
    
            update_post_meta( $post_id, 'part_details_json', json_encode( $part_details ) );
    
            wp_set_object_terms( $post_id, (int)$truck_part_tax_id, 'part_type', false );
    
            if (is_wp_error( $post_id )) {
                $errors = $post_id->get_error_messages();
                foreach ($errors as $error) {
                  echo $error;
                }
              }
    
          endif;
    
          // Reset Post Data
          wp_reset_postdata();

    The API fetch is fine and anything above the code seems to work properly. There are 18000+ posts in the database, everything in the database gets displayed properly. The cron job is set to hourly, but nothing gets saved. I am not sure if a recent WP version had anything to do with it. Any pointers would be greatly appreciated.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Information not saved in WPDB’ is closed to new replies.