Home Forums ACF PRO Pruning Orphaned Flex-field Data Reply To: Pruning Orphaned Flex-field Data

  • Thanks John, that is very helpful.

    Here’s the entirety of the function, its set to priority 0:

    public static function remove_orphans($post_id) {
            global $wpdb;
            $result = $wpdb->query($wpdb->prepare("
                DELETE FROM {$wpdb->postmeta}
                WHERE {$wpdb->postmeta}.post_id = %d
                AND (
                    meta_key LIKE '".static::PAGE_BUILDER_ACF_FIELD."_%'
                    OR meta_key LIKE '_".static::PAGE_BUILDER_ACF_FIELD."_%'

    It’s very straightforward, hence my confusion.

    The cache is interesting, I will give that a shot in a little bit and let you know if it works… Based on your description that does seem like it could be the source of some odd behavior.

    I don’t think it will be an issue in normal operation if this process gets skipped when no changes are made, but I would like to be able to force it so that I don’t have to go through everything and make arbitrary changes to trigger an update – do you know of an easy way to do so and/or what’s the name of the field ACF uses to track that?