get_field() is no less optimized that get_post_meta(), in fact, get_field() is just a wrapper for get_post_meta() that formats the value in a specific way before returning the value. If you use get_post_meta() then you need to do all that formatting work yourself anyway.
There can be times when you may be doing extra DB calls when getting one field at a time, but these conditions are rare. You might see some improvement by calling get_post_meta() without specifying a meta key before getting any fields. For example
$meta = get_post_meta($post_id);. What this does is forces WP to get all of the meta values for a post and to store those values into the cache so that no db calls will be needed to get values later on. After this you can go ahead and use the ACF functions as normal and be sure that no extra db calls are made.
The best bet you have for improved performance is to install one of the caching plugins that are available for WP. This stores a static version of the page so that it is only updated when a change is made, dependent on the settings you use for them.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF PRO’s Flexible Content field allows you to create smaller pieces of UI and compose them into whole flexible patterns. In our latest article, we show how to use it to create swappable site sections and integrate it all in a theme.https://t.co/ZRocH8oJSp— Advanced Custom Fields (@wp_acf) January 24, 2023
© 2023 Advanced Custom Fields.