Support

Account

Home Forums General Issues get_field vs get_fields resource calls Reply To: get_field vs get_fields resource calls

  • If you are seeing a different number of queries being done when using get_field() as apposed to get_fields(), there are some things you can to.

    The first thing is to call get_post_meta($post->ID), this will cause all of the meta values for a post to be loaded into the WP cache and then any additional calls will not create additional queries.

    calling get_fields() will cause the same thing to happen as the first option.

    Once this is done you don’t really need to use the array that’s returned, you can just use get_field('field_name') after that and these will get values from the cache and not do an additional query.

    I’m not really sure why you’d be seeing a difference in the number of queries unless you’re getting values from another post, not the current post in “The Loop”. Usually, I’ve found that when setting up a post WP automatically gets all the post meta values automatically.