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:
Is there a way I can call all options variables like I can with
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.
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.
To answer your question directly,
get_post_meta does just that: it fetches *post* meta.
The equivalent of this function for WordPress *options* data, is
wp_load_alloptions which you can read more about here.
Hope this helps 🙂
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 🙂
Running a few tests now but I will for sure! Thanks again!
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.
Glad you came right
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.