Support

Account

Home Forums Front-end Issues Optimize code to query Custom Fields as PHP memory limit error? Reply To: Optimize code to query Custom Fields as PHP memory limit error?

  • Hi @caram

    You could better optimize the code by making use of the get_field function instead of the get_post_meta function. This will allow ACF to cache data and only load it once (instead of twice in your case):

    
    <?php  if( get_field('yyy') ) { ?>
        <span class="info-detail"><?php  the_field('yyyy'); ?></span>
    <?php  } ?>
    

    This said, your code should not be maxing out memory limits, so it’s more likely to be a ‘too many plugins / functionality’ issue. Perhaps a server upgrade is needed or you can remove some plugins / functionality.

    Thanks
    E