Single Meta

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 called acf.

To monitor the process, it is recommended to enable the Developer Mode to display all WP & ACF meta data on every Posts, Terms, Users & Options Pages.

ACF Extended Single Meta

ACF Extended
Howdy, ACF Extended
Edit PageAdd New
WP Custom Fields
NameValue
_edit_last
1
_edit_lock
1611654170:1
acf
Array
(
    [_my_field] => field_5ffd218f27704
    [my_field] => Vestibulum ac diam sit amet
    [_my_date] => field_5ffd27b80a8af
    [my_date] => 20210831
)
a:4:{s:9:"_my_field";s:19:"field_5ffd218f27704";s:8:"my_field";s:27:"Vestibulum ac diam sit amet";s:8:"_my_date";s:19:"field_5ffd27b80a8af";s:7:"my_date";s:8:"20210831";}
Publish
Status: Published
Visibility: Public
Author

Normal ACF Meta

ACF Extended
Howdy, ACF Extended
Edit PageAdd New
WP Custom Fields
NameValue
_edit_last
1
_edit_lock
1611654170:1
ACF Custom Fields
NameValueField Group
_my_field
field_5ffd218f27704
My Field Group
my_field
Vestibulum ac diam sit amet
My Field Group
_my_date
field_5ffd27b80a8af
My Field Group
my_date
20210831
My Field Group
Publish
Status: Published
Visibility: Public
Author

Getting Started

The Single Meta module is disabled by default. It can be enabled and disabled in the Settings UIPRO, or with the following code:

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

    // Enable Single Meta
    acf_update_setting('acfe/modules/single_meta', true);
    
}

// Or using acfe/init
add_action('acfe/init', 'my_acfe_modules');
function my_acfe_modules(){
    
    // Enable Single Meta
    acfe_update_setting('modules/single_meta', true);
    
}

Enable on Specific Post Types

Additionally, you can set preferences to only enable the module on specific Post Types, Taxonomies and Options Pages.

// Enable Single Meta 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 on Specific Taxonomies

// Enable Single Meta 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 on Specific User Role

// Enable Single Meta on specific User Roles (default: disabled)
add_filter('acfe/modules/single_meta/users', 'my_acfe_single_meta_users');
function my_acfe_single_meta_users($user_roles){

    $user_roles = array('administrator', 'author');
    
    // Enable on all user roles
    // return array();

    // Disable all user roles (default behavior)
    // return false;

    return $user_roles;

}

Enable on Specific Options Pages


// Enable Single Meta on specific Options Post 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 behavior)
    // return false;

    return $options_ids;

}

Front-End WP Query

This module also enables a new setting available in every ACF Fields: “Save as Individual Meta”. WP Queries and Meta Queries can be used normally with ACF Fields only if the “Save as Individual Meta” setting is enabled on the ACF Fields that are queried.

Revert Back

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.