Home Forums General Issues What's faster? Reply To: What's faster?

  • (A) will be faster if you have a significant number of fields to get.

    I actually use a combination of the two.

    $allPostMeta	= get_post_meta($id);
    $item1 = get_field('item1', $id);
    $item2 = get_field('item2', $id);
    $item3 = get_field('item3', $id);
    // […]
    $itemN = get_field('itemN', $id);

    The reason is that the first statement makes WP get all of the meta values and put them in a cache, from that point on get_field() gets values from the WP cache and the ACF functions are easier for most people to use than trying to navigate a complicate array of meta data, especially if it might contain things like repeaters.

    As for gallery fields, and image fields, If you have many images then returning the image ID and getting specific image information based on the ID with standard WP functions like wp_get_attachment_image_src() will provide better performance than returning an image object/array in ACF.