Skip to main content

Performance Tips

When migrating content, suspend cache invalidation and flush the cache afterwards.

With that in mind, the following optimisation reduces the number of database queries to 1:

-		$post_data = [
-			'ID' => $post_id,
-			'post_content' => $content,
-		];
-
-		$updated = wp_update_post( $post_data, true );
+		$updated = $wpdb->update(
+			$wpdb->posts,
+			[
+				'post_content' => $content,
+			],
+			[
+				'ID' => $post_id,
+			]
+		);