Single Meta Save

Compress all fields values from the current post, term, user or options into one single meta data. This process lighten the database load as values are saved and read from one single row. Once activated and after saving a post/term/user in the administration, all old meta data will be removed and packed together in a meta called acf.

To monitor the process, it is possible to enable the “ACF Extended: Dev Mode” which will display all WP & ACF meta data on every Posts, Terms, Users & Options.

This feature also enables a new setting available in every fields: “Save as individual meta”. If this setting is turned ON on a specific field, then the value will be saved individually. WP Queries and Meta Queries can be used just like before.

Getting Started

Single Meta Save is disabled by default. To enable it, add the following code in your functions.php file:

add_action('acf/init', 'my_acfe_modules');
function my_acfe_modules(){

    // Enable Single Meta Save
    acfe_update_setting('modules/single_meta', true);

}

// Enable Single Meta Save on specific Post Types only (default: all)
add_filter('acfe/modules/single_meta/post_types', 'my_acfe_single_meta_post_types');
function my_acfe_single_meta_post_types($post_types){

    $post_types = array('page', 'my-post-type');

    // Disable all post types:
    // return false;

    return $post_types;

}

// Enable Single Meta Save on specific Taxonomies only (default: all)
add_filter('acfe/modules/single_meta/taxonomies', 'my_acfe_single_meta_taxonomies');
function my_acfe_single_meta_taxonomies($taxonomies){

    $taxonomies = array('category', 'my-taxonomy');

    // Disable all taxonomies:
    // return false;

    return $taxonomies;

}

// Enable Single Meta Save on specific Options ID (default: disabled)
add_filter('acfe/modules/single_meta/options', 'my_acfe_single_meta_options');
function my_acfe_single_meta_options($options_ids){

    $options_ids = array('options', 'my-option-id');

    // Disable all options id (default):
    // return false;

    return $options_ids;

}

Note: It is possible to revert back to the native ACF save process. To do so, keep the feature enabled, get in the post administration you want to revert back. Disable the feature in your code, and save the post. All data will be saved back to individual meta data.