Home › Forums › General Issues › Two Part thread: Dealing with Query count and global options
I was wondering if anyone had any suggestions for decreasing the amount of queries ACF calls.
Right now ACF calls 70 queries on my site and that seems a little high to me. I am using the:
get_post_meta($post->ID)
function to pull all the data. However this does not include anything from within the options table that I need to pull.
The two callers that seem to give me the most issue are:
get_option()
and update_meta_cache()
Is there a way I can call all options variables like I can with get_post_meta
?
Hi @rameden
Is there a reason you’re not using the ACF functions for this?
get_field('field_name')
to get a post/page specific meta field, or get_field('field_name', 'option')
to get a site options meta field.
Hi @markbloomfield,
The reason I am not using get_field('fieldname');
is due to the amount of custom fields I am using. I do not want to use a DB every time I need to display the field. Using get_post_meta($post->ID);
allows to me to only call the data once.
I didn’t even know wp_load_alloptions
was a thing! That is awesome!
@rameden learnt about it today too π
If this solves your problem, you can click on the ‘solved’ button for that answer, that’d be great π
Good luck!
Figured it out. When you initially setup your ACF options is defaults autoload to false. If you set it to true they will then show up.
You must be logged in to reply to this topic.
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!
π€ Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee youβre represented in the results. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.