Cloudflare is caching posts/products without images when imported using WP All Import

If you are using Cloudflare and WP All Import together, then most of the time this works perfectly well with External Images. We personally have never experienced issues, however we had this report from one customer and with the assistance of WP All Import and Cloudflare, they eventually got to the bottom of it.

The issue they described was that pages were appearing without images and then if they flushed the Cloudflare cache the images appeared.

This is what WP All Import said:

The problem is most likely that WP All Import creates the post and then adds the images/custom fields later, at which point Cloudflare has already cached the post without images.I looked through their plugin’s code and it looks like we can force them to purge the cache for an imported post by re-publishing it once it’s been imported.

How to fix images not appearing until you clear the Cloudflare cache

To fix the problem described above, if you experience it, add the following code to your functions.php file:

add_action( 'pmxi_saved_post', 'my_publish_post', 10, 3 );
function my_publish_post( $id, $xml, $update ) {
  wp_publish_post( $id );
}

Help us improve this KB article

If you have experienced the issue above, please comment below or comment on our Discord server. We have only had one report of this so far, so we’re keen to discover other potential issues. It seems like an issue with WP All Import and Cloudflare with Cloudflare thinking the post is published before the postmeta data has been saved.

Be the first to comment and we'll reply right away.

Leave a reply

Super Speedy Plugins
Logo