Home Forums General Issues Two Part thread: Dealing with Query count and global options


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.

  • Understand @rameden

    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 🙂

    Good luck!

  • Running a few tests now but I will for sure! Thanks again!

  • This reply has been marked as private.
  • 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.

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Two Part thread: Dealing with Query count and global options’ is closed to new replies.