Skip to content

get_field has cost in front end! it means when you perform this function it calls multiple time queries as you store data in your backend. in simple words if you had 1000 text box in your acf option back-end and you call acf get_field in front-end it will call mysql query 1000 times and if you want use acf and care about your performance you wil…

License

Notifications You must be signed in to change notification settings

devlifeX/acf-getallobjects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ACF getallobjects

FOR DEVELOPERS Only!

get_field has cost in front end! it means when you perform this function it calls multiple time queries as you store data in your backend. in simple words if you had 1000 text box in your acf option back-end and you call acf get_field in front-end it will call mysql query 1000 times and if you want use acf and care about your performance you will need to use this plugin or other approciate approche.

Before use this plugin

alt tag

After use this plugin

alt tag

How is work?

After save acf in backend this plugin create record in Database(wp_options) with this pattern (acfAllObjects+post_id) as key and put all your fields data as whole object in value. then you instead of get_fields('foo', 'option') you can use ACFAllObj::get('foo', 'option');

How to Use?

  1. Clone or Download in your plugins directory
$ git clone https://github.com/devlifeX/acf-getallobjects.git
  1. Activate plugin from wp-admin
  2. Go to your acf post type (option or custom post type etc...) and save again (for create acfAllObjects record)
  3. Go to your theme file and replace your current code with this structure
 if (class_exists('ACFAllObj')) {   
        $foo = ACFAllObj::get('foo', 'option');
        $bar = ACFAllObj::get('bar', 'option');
    } else {
        $foo = get_field('foo', 'option');
        $bar = get_field('bar', 'option');
    }

About

get_field has cost in front end! it means when you perform this function it calls multiple time queries as you store data in your backend. in simple words if you had 1000 text box in your acf option back-end and you call acf get_field in front-end it will call mysql query 1000 times and if you want use acf and care about your performance you wil…

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages