Support

Account

Home Forums General Issues Slow acf field syncing

Unread

Slow acf field syncing

  • Just spent a few hours debugging why I was getting such slow syncing times. Turns out the Yoast Seo plugin likes to ping google to recrawl the sitemap.xml when the status of any post changes. When importing a field group, acf seems to use wp_insert_post() for every field in the field group, which then triggers Yoast Seo to ping google like a couple hundred times depending on the size of your field group. This pinging is meant to be non-blocking but for whatever reason it actually blocks the entire page from loading. If anybody has been pulling their hair out like me, here’s the code that fixes it:

    
    // Prevent Yoas Seo plugin from pinging google (100s of times) 
    // to recrawl the sitemap.xml when syncing acf fields from json
    add_action('admin_init', 'prevent_yoast_from_pinging_google_on_acf_field_sync', 10, 0);
    function prevent_yoast_from_pinging_google_on_acf_field_sync() {
      if (isset($_GET['acfsync'])) {
        add_filter('wpseo_allow_xml_sitemap_ping', '__return_false');
      }
    }
    
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.